File tree 1 file changed +8
-4
lines changed
java/src/org/openqa/selenium/remote
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) {
1148
1148
// simulate search by name
1149
1149
String original = getWindowHandle ();
1150
1150
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
1154
1158
}
1155
1159
}
1156
- switchTo (). window (original );
1160
+ execute ( DriverCommand . SWITCH_TO_WINDOW (original ) );
1157
1161
throw nsw ;
1158
1162
}
1159
1163
}
You can’t perform that action at this time.
0 commit comments