Skip to content

Commit cbe914b

Browse files
committed
magento-research/pwa-tests#MQE-1382-WaitForReactPageLoad
- Created a separate Class for the custom PWA actions. - Removed the custom PWA actions from MagentoWebDriver.
1 parent 149332a commit cbe914b

File tree

2 files changed

+59
-42
lines changed

2 files changed

+59
-42
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\FunctionalTestingFramework\Module;
8+
9+
/**
10+
* Class MagentoPwaActions
11+
*
12+
* Contains all custom PWA action functions to be used in PWA tests.
13+
*
14+
* @package Magento\FunctionalTestingFramework\Module
15+
*/
16+
class MagentoPwaWebDriver extends MagentoWebDriver
17+
{
18+
/**
19+
* Wait for a PWA Element to NOT be visible using JavaScript.
20+
*
21+
* @param null $selector
22+
* @param null $timeout
23+
* @throws \Exception
24+
* @return void
25+
*/
26+
public function waitForPwaElementNotVisible($selector, $timeout = null)
27+
{
28+
$timeout = $timeout ?? $this->_getConfig()['pageload_timeout'];
29+
30+
// Determine what type of Selector is used.
31+
// Then use the correct JavaScript to locate the Element.
32+
if (\Codeception\Util\Locator::isXPath($selector)) {
33+
$this->waitForJS("return !document.evaluate(`$selector`, document);", $timeout);
34+
} else {
35+
$this->waitForJS("return !document.querySelector(`$selector`);", $timeout);
36+
}
37+
}
38+
39+
/**
40+
* Wait for a PWA Element to be visible using JavaScript.
41+
*
42+
* @param null $selector
43+
* @param null $timeout
44+
* @throws \Exception
45+
* @return void
46+
*/
47+
public function waitForPwaElementVisible($selector, $timeout = null)
48+
{
49+
$timeout = $timeout ?? $this->_getConfig()['pageload_timeout'];
50+
51+
// Determine what type of Selector is used.
52+
// Then use the correct JavaScript to locate the Element.
53+
if (\Codeception\Util\Locator::isXPath($selector)) {
54+
$this->waitForJS("return !!document && !!document.evaluate(`$selector`, document);", $timeout);
55+
} else {
56+
$this->waitForJS("return !!document && !!document.querySelector(`$selector`);", $timeout);
57+
}
58+
}
59+
}

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -379,48 +379,6 @@ public function waitForPageLoad($timeout = null)
379379
$this->waitForLoadingMaskToDisappear($timeout);
380380
}
381381

382-
/**
383-
* Wait for a PWA Element to NOT be visible using JavaScript.
384-
*
385-
* @param null $selector
386-
* @param null $timeout
387-
* @throws \Exception
388-
* @return void
389-
*/
390-
public function waitForPwaElementNotVisible($selector, $timeout = null)
391-
{
392-
$timeout = $timeout ?? $this->_getConfig()['pageload_timeout'];
393-
394-
// Determine what type of Selector is used.
395-
// Then use the correct JavaScript to locate the Element.
396-
if (\Codeception\Util\Locator::isXPath($selector)) {
397-
$this->waitForJS("return !document.evaluate(`$selector`, document);", $timeout);
398-
} else {
399-
$this->waitForJS("return !document.querySelector(`$selector`);", $timeout);
400-
}
401-
}
402-
403-
/**
404-
* Wait for a PWA Element to be visible using JavaScript.
405-
*
406-
* @param null $selector
407-
* @param null $timeout
408-
* @throws \Exception
409-
* @return void
410-
*/
411-
public function waitForPwaElementVisible($selector, $timeout = null)
412-
{
413-
$timeout = $timeout ?? $this->_getConfig()['pageload_timeout'];
414-
415-
// Determine what type of Selector is used.
416-
// Then use the correct JavaScript to locate the Element.
417-
if (\Codeception\Util\Locator::isXPath($selector)) {
418-
$this->waitForJS("return !!document && !!document.evaluate(`$selector`, document);", $timeout);
419-
} else {
420-
$this->waitForJS("return !!document && !!document.querySelector(`$selector`);", $timeout);
421-
}
422-
}
423-
424382
/**
425383
* Wait for all visible loading masks to disappear. Gets all elements by mask selector, then loops over them.
426384
*

0 commit comments

Comments
 (0)