-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathMagentoPwaWebDriver.php
59 lines (54 loc) · 1.84 KB
/
MagentoPwaWebDriver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\FunctionalTestingFramework\Module;
/**
* Class MagentoPwaActions
*
* Contains all custom PWA action functions to be used in PWA tests.
*
* @package Magento\FunctionalTestingFramework\Module
*/
class MagentoPwaWebDriver extends MagentoWebDriver
{
/**
* Wait for a PWA Element to NOT be visible using JavaScript.
*
* @param null $selector
* @param null $timeout
* @throws \Exception
* @return void
*/
public function waitForPwaElementNotVisible($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.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);
}
}
}