File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
java/src/org/openqa/selenium/remote Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -1148,12 +1148,16 @@ public WebDriver window(String windowHandleOrName) {
11481148 // simulate search by name
11491149 String original = getWindowHandle ();
11501150 for (String handle : getWindowHandles ()) {
1151- switchTo ().window (handle );
1152- if (windowHandleOrName .equals (executeScript ("return window.name" ))) {
1153- return RemoteWebDriver .this ; // found by name
1151+ try {
1152+ execute (DriverCommand .SWITCH_TO_WINDOW (handle ));
1153+ if (windowHandleOrName .equals (executeScript ("return window.name" ))) {
1154+ return RemoteWebDriver .this ; // found by name
1155+ }
1156+ } catch (NoSuchWindowException nswe ) {
1157+ // swallow
11541158 }
11551159 }
1156- switchTo (). window (original );
1160+ execute ( DriverCommand . SWITCH_TO_WINDOW (original ) );
11571161 throw nsw ;
11581162 }
11591163 }
You can’t perform that action at this time.
0 commit comments