17
17
*/
18
18
class MagentoPwaWebDriver extends MagentoWebDriver
19
19
{
20
+ /**
21
+ * List of known PWA loading masks by selector
22
+ *
23
+ * Overriding the MagentoWebDriver array to contain applicable PWA locators.
24
+ *
25
+ * @var array
26
+ */
27
+ protected $ loadingMasksLocators = [
28
+ '//div[contains(@class, "indicator-global-3ae")] ' ,
29
+ '//div[contains(@class, "indicator-message-2he")] '
30
+ ];
31
+
20
32
/**
21
33
* Go to the page.
22
34
*
23
35
* Overriding the MagentoWebDriver version because it contains 'waitForPageLoad'.
24
36
* The AJAX check in 'waitForPageLoad' does NOT work with a PWA.
25
37
*
26
38
* @param string $page
39
+ * @param null $timeout
27
40
* @throws \Exception
28
41
* @return void
29
42
*/
30
- public function amOnPage ($ page )
43
+ public function amOnPage ($ page, $ timeout = null )
31
44
{
32
45
WebDriver::amOnPage ($ page );
46
+ $ this ->waitForLoadingMaskToDisappear ($ timeout );
33
47
}
34
48
35
49
/**
@@ -43,11 +57,15 @@ public function amOnPage($page)
43
57
*/
44
58
public function waitForPwaElementNotVisible ($ selector , $ timeout = null )
45
59
{
60
+ $ timeout = $ timeout ?? $ this ->_getConfig ()['pageload_timeout ' ];
61
+
46
62
// Determine what type of Selector is used.
47
63
// Then use the correct JavaScript to locate the Element.
48
64
if (\Codeception \Util \Locator::isXPath ($ selector )) {
65
+ $ this ->waitForLoadingMaskToDisappear ($ timeout );
49
66
$ this ->waitForJS ("return !document.evaluate(` $ selector`, document); " , $ timeout );
50
67
} else {
68
+ $ this ->waitForLoadingMaskToDisappear ($ timeout );
51
69
$ this ->waitForJS ("return !document.querySelector(` $ selector`); " , $ timeout );
52
70
}
53
71
}
@@ -63,11 +81,15 @@ public function waitForPwaElementNotVisible($selector, $timeout = null)
63
81
*/
64
82
public function waitForPwaElementVisible ($ selector , $ timeout = null )
65
83
{
84
+ $ timeout = $ timeout ?? $ this ->_getConfig ()['pageload_timeout ' ];
85
+
66
86
// Determine what type of Selector is used.
67
87
// Then use the correct JavaScript to locate the Element.
68
88
if (\Codeception \Util \Locator::isXPath ($ selector )) {
89
+ $ this ->waitForLoadingMaskToDisappear ($ timeout );
69
90
$ this ->waitForJS ("return !!document && !!document.evaluate(` $ selector`, document); " , $ timeout );
70
91
} else {
92
+ $ this ->waitForLoadingMaskToDisappear ($ timeout );
71
93
$ this ->waitForJS ("return !!document && !!document.querySelector(` $ selector`); " , $ timeout );
72
94
}
73
95
}
0 commit comments