From 14bf3c3cbec3b2962ada65d5d91c76e16033874c Mon Sep 17 00:00:00 2001 From: Vincent Dauce Date: Tue, 3 Mar 2020 12:12:24 +0100 Subject: [PATCH 1/2] Update switchToIFrame --- src/Codeception/Module/WebDriver.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Codeception/Module/WebDriver.php b/src/Codeception/Module/WebDriver.php index bcff0d37..d05bf562 100644 --- a/src/Codeception/Module/WebDriver.php +++ b/src/Codeception/Module/WebDriver.php @@ -2528,30 +2528,25 @@ public function switchToWindow($name = null) * ``` php * switchToIFrame("another_frame"); + * $I->switchToIFrame("iframe[name='another_frame']"); * # switch to parent page * $I->switchToIFrame(); * * ``` * - * @param string|null $name + * @param string|null $cssOrXPath */ - public function switchToIFrame($name = null) + public function switchToIFrame($cssOrXPath = null) { - if (is_null($name)) { + if (is_null($cssOrXPath)) { $this->webDriver->switchTo()->defaultContent(); return; } - try { - $this->webDriver->switchTo()->frame($name); - } catch (\Exception $e) { - $this->debug('Iframe was not found by name, locating iframe by CSS or XPath'); - $frames = $this->_findElements($name); - if (!count($frames)) { - throw $e; - } - $this->webDriver->switchTo()->frame($frames[0]); + $frames = $this->_findElements($cssOrXPath); + if (!count($frames)) { + throw $e; } + $this->webDriver->switchTo()->frame($frames[0]); } /** From 8d952916e9930de8e9ec11f6ea8147379af8dfd0 Mon Sep 17 00:00:00 2001 From: Vincent Dauce Date: Tue, 3 Mar 2020 15:36:30 +0100 Subject: [PATCH 2/2] Update WebDriver.php --- src/Codeception/Module/WebDriver.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Codeception/Module/WebDriver.php b/src/Codeception/Module/WebDriver.php index d05bf562..34a1f3aa 100644 --- a/src/Codeception/Module/WebDriver.php +++ b/src/Codeception/Module/WebDriver.php @@ -2521,32 +2521,39 @@ public function switchToWindow($name = null) * * Example: * ``` html - *