@@ -63,12 +63,13 @@ public function waitForPwaElementNotVisible($selector, $timeout = null)
6363
6464 // Determine what type of Selector is used.
6565 // Then use the correct JavaScript to locate the Element.
66- if (\Codeception \Util \Locator::isXPath ($ selector )) {
66+ if (\Codeception \Util \Locator::isCss ($ selector )) {
6767 $ this ->waitForLoadingMaskToDisappear ($ timeout );
68- $ this ->waitForJS ("return !document.evaluate (` $ selector`, document ); " , $ timeout );
68+ $ this ->waitForJS ("return !document.querySelector (` $ selector`); " , $ timeout );
6969 } else {
7070 $ this ->waitForLoadingMaskToDisappear ($ timeout );
71- $ this ->waitForJS ("return !document.querySelector(` $ selector`); " , $ timeout );
71+ $ this ->waitForJS ("return !document.evaluate(` $ selector`, document, null,
72+ XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; " , $ timeout );
7273 }
7374 }
7475
@@ -84,15 +85,16 @@ public function waitForPwaElementNotVisible($selector, $timeout = null)
8485 public function waitForPwaElementVisible ($ selector , $ timeout = null )
8586 {
8687 $ timeout = $ timeout ?? $ this ->_getConfig ()['pageload_timeout ' ];
87-
88+
8889 // Determine what type of Selector is used.
8990 // Then use the correct JavaScript to locate the Element.
90- if (\Codeception \Util \Locator::isXPath ($ selector )) {
91+ if (\Codeception \Util \Locator::isCss ($ selector )) {
9192 $ this ->waitForLoadingMaskToDisappear ($ timeout );
92- $ this ->waitForJS ("return !!document && !!document.evaluate (` $ selector`, document ); " , $ timeout );
93+ $ this ->waitForJS ("return !!document && !!document.querySelector (` $ selector`); " , $ timeout );
9394 } else {
9495 $ this ->waitForLoadingMaskToDisappear ($ timeout );
95- $ this ->waitForJS ("return !!document && !!document.querySelector(` $ selector`); " , $ timeout );
96+ $ this ->waitForJS ("return !!document && !!document.evaluate(` $ selector`, document, null,
97+ XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; " , $ timeout );
9698 }
9799 }
98100}
0 commit comments