diff --git a/src/Codeception/Module/WebDriver.php b/src/Codeception/Module/WebDriver.php index 01a742a3..69354aed 100644 --- a/src/Codeception/Module/WebDriver.php +++ b/src/Codeception/Module/WebDriver.php @@ -1255,7 +1255,7 @@ protected function findFields($selector): array } if (is_array($selector) || ($selector instanceof WebDriverBy)) { - $fields = $this->match($this->webDriver, $selector); + $fields = $this->match($this->getBaseElement(), $selector); if (empty($fields)) { throw new ElementNotFound($selector); @@ -1272,20 +1272,20 @@ protected function findFields($selector): array ".//label[contains(normalize-space(string(.)), {$locator})]//.//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]" // @codingStandardsIgnoreEnd ); - $fields = $this->webDriver->findElements(WebDriverBy::xpath($xpath)); + $fields = $this->getBaseElement()->findElements(WebDriverBy::xpath($xpath)); if (!empty($fields)) { return $fields; } // by name $xpath = ".//*[self::input | self::textarea | self::select][@name = {$locator}]"; - $fields = $this->webDriver->findElements(WebDriverBy::xpath($xpath)); + $fields = $this->getBaseElement()->findElements(WebDriverBy::xpath($xpath)); if (!empty($fields)) { return $fields; } // try to match by CSS or XPath - $fields = $this->match($this->webDriver, $selector, false); + $fields = $this->match($this->getBaseElement(), $selector, false); if (!empty($fields)) { return $fields; } diff --git a/tests/data/app/view/form/bug79.php b/tests/data/app/view/form/bug79.php new file mode 100644 index 00000000..902f783e --- /dev/null +++ b/tests/data/app/view/form/bug79.php @@ -0,0 +1,15 @@ + + + + +
+ + + +
+ + +
+
+ + diff --git a/tests/unit/Codeception/Module/TestsForWeb.php b/tests/unit/Codeception/Module/TestsForWeb.php index def42c28..2b32ab32 100644 --- a/tests/unit/Codeception/Module/TestsForWeb.php +++ b/tests/unit/Codeception/Module/TestsForWeb.php @@ -4,6 +4,7 @@ use Codeception\Module\WebDriver; use Codeception\Test\Unit; +use Codeception\Util\ActionSequence; /** * Author: davert @@ -1745,4 +1746,24 @@ public function testPasswordArgument() $data = data::get('form'); $this->assertEquals('thisissecret', $data['password']); } + + /** + * @see https://github.com/Codeception/module-webdriver/issues/79 + */ + public function testFieldActionsWithPerformOn() + { + $this->module->amOnPage('/form/bug79'); + $this->module->performOn( + ['class' => 'nested'], + ActionSequence::build()->fillField('Title', 'Test') + ); + + $this->module->dontSeeInField('#title-1', 'Test'); + $this->module->seeInField('#title-2', 'Test'); + + $title1Value = $this->module->grabValueFrom('#title-1'); + $this->assertEmpty($title1Value); + $title2Value = $this->module->grabValueFrom('#title-2'); + $this->assertEquals('Test', $title2Value); + } }