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)
25242524 $ this ->webDriver ->switchTo ()->defaultContent ();
25252525 return ;
25262526 }
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+ }
25282537 }
25292538
25302539 /**
Original file line number Diff line number Diff line change @@ -1081,6 +1081,11 @@ public function testSwitchToIframe()
10811081 $ this ->module ->see ('Lots of valuable data here ' );
10821082 $ this ->module ->switchToIFrame ();
10831083 $ 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+
10841089 }
10851090
10861091 public function testGrabPageSourceWhenNotOnPage ()
You can’t perform that action at this time.
0 commit comments