1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pagantis\SeleniumFormUtils\Step; |
4
|
|
|
|
5
|
|
|
use Facebook\WebDriver\WebDriver; |
6
|
|
|
use Facebook\WebDriver\WebDriverBy; |
7
|
|
|
use Facebook\WebDriver\WebDriverExpectedCondition; |
8
|
|
|
use Faker\Factory; |
9
|
|
|
use Pagantis\SeleniumFormUtils\SeleniumHelper; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class AbstractStep |
13
|
|
|
* |
14
|
|
|
* @package Pagantis\SeleniumFormUtils\Step |
15
|
|
|
*/ |
16
|
|
|
abstract class AbstractStep implements StepInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var WebDriver |
20
|
|
|
*/ |
21
|
|
|
protected $webDriver; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var Factory |
25
|
|
|
*/ |
26
|
|
|
protected $faker; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* AbstractStep constructor. |
30
|
|
|
* |
31
|
|
|
* @param WebDriver $webDriver |
32
|
|
|
*/ |
33
|
|
|
public function __construct(WebDriver $webDriver) |
34
|
|
|
{ |
35
|
|
|
$this->webDriver = $webDriver; |
36
|
|
|
$this->faker = Factory::create(); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param WebDriverBy $webDriverBy |
41
|
|
|
* |
42
|
|
|
* @return \Facebook\WebDriver\WebDriverElement |
43
|
|
|
* |
44
|
|
|
* @throws \Facebook\WebDriver\Exception\NoSuchElementException |
45
|
|
|
* @throws \Facebook\WebDriver\Exception\TimeOutException |
46
|
|
|
*/ |
47
|
|
|
public function waitTobeClickAble(WebDriverBy $webDriverBy) |
48
|
|
|
{ |
49
|
|
|
$condition = WebDriverExpectedCondition::elementToBeClickable($webDriverBy); |
50
|
|
|
$this->webDriver->wait(90, 1500)->until($condition); |
51
|
|
|
|
52
|
|
|
return $this->webDriver->findElement($webDriverBy); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param WebDriverBy $webDriverBy |
57
|
|
|
* |
58
|
|
|
* @return \Facebook\WebDriver\WebDriverElement |
59
|
|
|
* |
60
|
|
|
* @throws \Facebook\WebDriver\Exception\NoSuchElementException |
61
|
|
|
* @throws \Facebook\WebDriver\Exception\TimeOutException |
62
|
|
|
*/ |
63
|
|
|
public function waitTobeVisible(WebDriverBy $webDriverBy) |
64
|
|
|
{ |
65
|
|
|
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($webDriverBy); |
66
|
|
|
$this->webDriver->wait(90, 1500)->until($condition); |
67
|
|
|
|
68
|
|
|
return $this->webDriver->findElement($webDriverBy); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param string $step |
73
|
|
|
* |
74
|
|
|
* @throws \Exception |
75
|
|
|
*/ |
76
|
|
|
public function validateStep($step) |
77
|
|
|
{ |
78
|
|
|
$currentStep = SeleniumHelper::$arraySteps[ |
79
|
|
|
$this->webDriver->findElement(WebDriverBy::cssSelector(".ProgressBar progress")) |
80
|
|
|
->getAttribute("value") |
81
|
|
|
]; |
82
|
|
|
|
83
|
|
|
if ($step !== $currentStep) { |
84
|
|
|
throw new \Exception('Wrong step: ' . $arraySteps[$step]); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param $iFrameLocator |
90
|
|
|
* |
91
|
|
|
* @throws \Facebook\WebDriver\Exception\NoSuchElementException |
92
|
|
|
* @throws \Facebook\WebDriver\Exception\TimeOutException |
93
|
|
|
*/ |
94
|
|
|
public function moveToIFrame($iFrameLocator) |
95
|
|
|
{ |
96
|
|
|
$condition = WebDriverExpectedCondition::frameToBeAvailableAndSwitchToIt($iFrameLocator); |
97
|
|
|
$this->webDriver->wait(90, 1500)->until($condition); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Switch to parent window |
102
|
|
|
*/ |
103
|
|
|
public function moveToParent() |
104
|
|
|
{ |
105
|
|
|
$handles=$this->webDriver->getWindowHandles(); |
106
|
|
|
$parent = end($handles); |
107
|
|
|
$this->webDriver->switchTo()->window($parent); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..