File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -2524,7 +2524,16 @@ public function switchToIFrame($name = null)
2524
2524
$ this ->webDriver ->switchTo ()->defaultContent ();
2525
2525
return ;
2526
2526
}
2527
- $ this ->webDriver ->switchTo ()->frame ($ name );
2527
+ try {
2528
+ $ this ->webDriver ->switchTo ()->frame ($ name );
2529
+ } catch (\Exception $ e ) {
2530
+ $ this ->debug ('Iframe was not found by name, locating iframe by CSS or XPath ' );
2531
+ $ frames = $ this ->_findElements ($ name );
2532
+ if (!count ($ frames )) {
2533
+ throw $ e ;
2534
+ }
2535
+ $ this ->webDriver ->switchTo ()->frame ($ frames [0 ]);
2536
+ }
2528
2537
}
2529
2538
2530
2539
/**
Original file line number Diff line number Diff line change @@ -1081,6 +1081,11 @@ public function testSwitchToIframe()
1081
1081
$ this ->module ->see ('Lots of valuable data here ' );
1082
1082
$ this ->module ->switchToIFrame ();
1083
1083
$ this ->module ->see ('Iframe test ' );
1084
+ $ this ->module ->switchToIFrame ('iframe ' );
1085
+ $ this ->module ->see ('Lots of valuable data here ' );
1086
+ $ this ->module ->switchToIFrame ();
1087
+ $ this ->module ->see ('Iframe test ' );
1088
+
1084
1089
}
1085
1090
1086
1091
public function testGrabPageSourceWhenNotOnPage ()
You can’t perform that action at this time.
0 commit comments