I can help you with generic answer here.
1.) Using driver.getWindowHandles() and store all Window Handles to List<String> variable.
2.) Store current window handle using driver.getCurrentWindowHandle(). So, you are sure you do not switch to the current window during iterating.
3.) Store IInd window title into any string variable say window2title.
4.) Store IIIrd window title to String variable say window3title.
Now you can loop through as given below.
public void sample_psudo_swith_code(){
String currentWindowHandle = driver.getCurrentWindowHandle();
String window2title = "your title here";
String window3title = "your title here";
switch_to_window(currentWindowHandle,window3title );
//... do your work here with window 3
switch_to_window(currentWindowHandle,window2title );
driver.close(); //switching closing IInd window.
switch_to_window(currentWindowHandle );
}
public void switch_to_window(String windowHandle){
driver.switchTo().window(windowHandle);
}
public void switch_to_window(String currentWindowHandle, String title){
List<String> handles = driver.getWindowHandles();
while(String handle : handles){
if(!handle.equals(currentWindowHandle)){
driver.switchTo().window(handle);
if(driver.getTitle().equals(title)) return;
}
}
}