diff --git a/etc/di.xml b/etc/di.xml index 60faed3a0..3e6313bf3 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -8,7 +8,7 @@ + ]> diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoPwaWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoPwaWebDriver.php new file mode 100644 index 000000000..98b13fe90 --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoPwaWebDriver.php @@ -0,0 +1,59 @@ +_getConfig()['pageload_timeout']; + + // Determine what type of Selector is used. + // Then use the correct JavaScript to locate the Element. + if (\Codeception\Util\Locator::isXPath($selector)) { + $this->waitForJS("return !document.evaluate(`$selector`, document);", $timeout); + } else { + $this->waitForJS("return !document.querySelector(`$selector`);", $timeout); + } + } + + /** + * Wait for a PWA Element to be visible using JavaScript. + * + * @param null $selector + * @param null $timeout + * @throws \Exception + * @return void + */ + public function waitForPwaElementVisible($selector, $timeout = null) + { + $timeout = $timeout ?? $this->_getConfig()['pageload_timeout']; + + // Determine what type of Selector is used. + // Then use the correct JavaScript to locate the Element. + if (\Codeception\Util\Locator::isXPath($selector)) { + $this->waitForJS("return !!document && !!document.evaluate(`$selector`, document);", $timeout); + } else { + $this->waitForJS("return !!document && !!document.querySelector(`$selector`);", $timeout); + } + } +} diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/waitActions.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/waitActions.xsd index 5350d9d3e..70b8201a1 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/waitActions.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/waitActions.xsd @@ -20,6 +20,8 @@ + + @@ -165,7 +167,7 @@ - Waits up to given time for page to have finished loading.. + Waits up to given time for page to have finished loading. @@ -176,6 +178,36 @@ + + + + Waits up to given time for a PWA Element to disappear from the screen using JavaScript. + + + + + + + + + + + + + + + Waits up to given time for a PWA Element to appear on the screen using JavaScript. + + + + + + + + + + + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 4113f96ee..abc62eb20 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -1045,6 +1045,8 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato case "waitForElement": case "waitForElementVisible": case "waitForElementNotVisible": + case "waitForPwaElementVisible": + case "waitForPwaElementNotVisible": $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $time); break; case "waitForPageLoad":