1 | <?php |
||
15 | class GenericFeatureContext extends MinkContext |
||
16 | { |
||
17 | /** @var int UI generic delay duration in milliseconds */ |
||
18 | const DELAY = 1000; |
||
19 | /** @var int UI javascript generic delay duration in milliseconds */ |
||
20 | const JS_DELAY = self::DELAY / 5; |
||
21 | /** @var int UI spin function delay */ |
||
22 | const SPIN_TIMEOUT = self::DELAY / 20; |
||
23 | |||
24 | /** @var mixed */ |
||
25 | protected $session; |
||
26 | |||
27 | /** |
||
28 | * Initializes context. |
||
29 | * |
||
30 | * Every scenario gets its own context instance. |
||
31 | * You can also pass arbitrary arguments to the |
||
32 | * context constructor through behat.yml. |
||
33 | * |
||
34 | * @param mixed $session |
||
35 | */ |
||
36 | public function __construct($session = null) |
||
42 | |||
43 | /** |
||
44 | * Spin function to avoid Selenium fails. |
||
45 | * |
||
46 | * @param callable $lambda |
||
47 | * @param int $wait |
||
48 | * |
||
49 | * @return bool |
||
50 | * @throws \Exception |
||
51 | */ |
||
52 | public function spin(callable $lambda, $wait = self::SPIN_TIMEOUT) |
||
73 | |||
74 | /** |
||
75 | * @AfterStep |
||
76 | * |
||
77 | * @param AfterStepScope $scope |
||
78 | */ |
||
79 | public function takeScreenShotAfterFailedStep(AfterStepScope $scope) |
||
93 | |||
94 | /** |
||
95 | * Find all elements by CSS selector. |
||
96 | * |
||
97 | * @param string $selector CSS selector |
||
98 | * |
||
99 | * @throws \InvalidArgumentException If element not found |
||
100 | * |
||
101 | * @return \Behat\Mink\Element\NodeElement[] |
||
102 | */ |
||
103 | protected function findAllByCssSelector(string $selector) |
||
116 | |||
117 | /** |
||
118 | * Find element by CSS selector. |
||
119 | * |
||
120 | * @param string $selector CSS selector |
||
121 | * |
||
122 | * @throws \InvalidArgumentException If element not found |
||
123 | * |
||
124 | * @return \Behat\Mink\Element\NodeElement |
||
125 | */ |
||
126 | protected function findByCssSelector(string $selector) : NodeElement |
||
130 | |||
131 | /** |
||
132 | * @Given /^I set browser window size to "([^"]*)" x "([^"]*)"$/ |
||
133 | * |
||
134 | * @param int $width Browser window width |
||
135 | * @param int $height Browser window height |
||
136 | */ |
||
137 | public function iSetBrowserWindowSizeToX($width, $height) |
||
141 | |||
142 | /** |
||
143 | * @Given /^I wait "([^"]*)" milliseconds for response$/ |
||
144 | * |
||
145 | * @param int $delay Amount of milliseconds to wait |
||
146 | */ |
||
147 | public function iWaitMillisecondsForResponse($delay = self::DELAY) |
||
151 | |||
152 | /** |
||
153 | * Click on the element with the provided xpath query. |
||
154 | * |
||
155 | * @When I click on the element :arg1 |
||
156 | * |
||
157 | * @param string $selector CSS element selector |
||
158 | * |
||
159 | * @throws \InvalidArgumentException |
||
160 | */ |
||
161 | public function iClickOnTheElement(string $selector) |
||
166 | |||
167 | /** |
||
168 | * @When /^I hover over the element "([^"]*)"$/ |
||
169 | * |
||
170 | * @param string $selector CSS element selector |
||
171 | * |
||
172 | * @throws \InvalidArgumentException |
||
173 | */ |
||
174 | public function iHoverOverTheElement(string $selector) |
||
178 | |||
179 | /** |
||
180 | * Fill in input with the provided info. |
||
181 | * |
||
182 | * @When I fill in the input :arg1 with :arg2 |
||
183 | * |
||
184 | * @param string $selector CSS element selector |
||
185 | * @param string $value Element value for filling in |
||
186 | * |
||
187 | * @throws \InvalidArgumentException |
||
188 | */ |
||
189 | public function iFillInTheElement(string $selector, string $value) |
||
193 | |||
194 | /** |
||
195 | * @When I scroll vertically to :arg1 px |
||
196 | * |
||
197 | * @param mixed $yPos Vertical scrolling position in pixels |
||
198 | */ |
||
199 | public function iScrollVerticallyToPx($yPos) |
||
203 | |||
204 | /** |
||
205 | * @When I scroll horizontally to :arg1 px |
||
206 | * |
||
207 | * @param mixed $xPos Horizontal scrolling position in pixels |
||
208 | */ |
||
209 | public function iScrollHorizontallyToPx($xPos) |
||
213 | |||
214 | /** |
||
215 | * @Given /^I fill hidden field "([^"]*)" with "([^"]*)"$/ |
||
216 | * |
||
217 | * @param string $field Field name |
||
218 | * @param string $value Field value |
||
219 | */ |
||
220 | public function iFillHiddenFieldWith(string $field, string $value) |
||
227 | |||
228 | /** |
||
229 | * @Then I check custom checkbox with :id |
||
230 | * |
||
231 | * @param string $id Checkbox identifier |
||
232 | * |
||
233 | * @throws \InvalidArgumentException If checkbox with provided identifier does not exists |
||
234 | */ |
||
235 | public function iCheckCustomCheckboxWith(string $id) |
||
248 | |||
249 | /** |
||
250 | * @Then I drag element :selector to :target |
||
251 | * |
||
252 | * @param string $selector Source element for dragging |
||
253 | * @param string $target Target element to drag to |
||
254 | * |
||
255 | * @throws \InvalidArgumentException |
||
256 | */ |
||
257 | public function dragElementTo(string $selector, string $target) |
||
263 | |||
264 | /** |
||
265 | * Fill in input with the provided info. |
||
266 | * |
||
267 | * @When I fill in the element :arg1 with value :arg2 using js |
||
268 | * |
||
269 | * @param string $selector CSS element selector |
||
270 | * @param string $value Element value for filling in |
||
271 | */ |
||
272 | public function iFillInTheElementUsingJs(string $selector, string $value) |
||
276 | } |
||
277 |