1 | <?php |
||
13 | class TqContext extends RawTqContext |
||
14 | { |
||
15 | use LogicalAssertion; |
||
16 | |||
17 | /** |
||
18 | * The name and working element of main window. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | private $mainWindow = []; |
||
23 | /** |
||
24 | * @var Database |
||
25 | */ |
||
26 | private static $database; |
||
27 | |||
28 | /** |
||
29 | * Supports switching between the two windows only. |
||
30 | * |
||
31 | * @Given /^(?:|I )switch to opened window$/ |
||
32 | * @Then /^(?:|I )switch back to main window$/ |
||
33 | */ |
||
34 | public function iSwitchToWindow() |
||
54 | |||
55 | /** |
||
56 | * @Given /^(?:|I )switch to CKFinder window$/ |
||
57 | * |
||
58 | * @javascript |
||
59 | */ |
||
60 | public function switchToCKFinderWindow() |
||
69 | |||
70 | /** |
||
71 | * @param string $name |
||
72 | * An iframe name (null for switching back). |
||
73 | * |
||
74 | * @Given /^(?:|I )switch to an iframe "([^"]*)"$/ |
||
75 | * @Then /^(?:|I )switch back from an iframe$/ |
||
76 | */ |
||
77 | public function iSwitchToAnIframe($name = null) |
||
81 | |||
82 | /** |
||
83 | * Open the page with specified resolution. |
||
84 | * |
||
85 | * @param string $width_height |
||
86 | * String that satisfy the condition "<WIDTH>x<HEIGHT>". |
||
87 | * |
||
88 | * @example |
||
89 | * Given I should use the "1280x800" resolution |
||
90 | * |
||
91 | * @Given /^(?:|I should )use the "([^"]*)" screen resolution$/ |
||
92 | */ |
||
93 | public function useScreenResolution($width_height) |
||
99 | |||
100 | /** |
||
101 | * @param string $action |
||
102 | * The next actions can be: "press", "click", "double click" and "right click". |
||
103 | * @param string $selector |
||
104 | * CSS, inaccurate text or selector name from behat.yml can be used. |
||
105 | * |
||
106 | * @throws \WebDriver\Exception\NoSuchElement |
||
107 | * When element was not found. |
||
108 | * |
||
109 | * @Given /^(?:|I )((?:|(?:double|right) )click|press) on "([^"]*)"$/ |
||
110 | */ |
||
111 | public function pressElement($action, $selector) |
||
119 | |||
120 | /** |
||
121 | * @Given /^(?:|I )wait until AJAX is finished$/ |
||
122 | * |
||
123 | * @javascript |
||
124 | */ |
||
125 | public function waitUntilAjaxIsFinished() |
||
129 | |||
130 | /** |
||
131 | * @param string $selector |
||
132 | * CSS selector or region name. |
||
133 | * |
||
134 | * @Then /^(?:|I )work with elements in "([^"]*)"(?:| region)$/ |
||
135 | */ |
||
136 | public function workWithElementsInRegion($selector) |
||
146 | |||
147 | /** |
||
148 | * @Then /^(?:|I )checkout to whole page$/ |
||
149 | */ |
||
150 | public function unsetWorkingElementScope() |
||
154 | |||
155 | /** |
||
156 | * @param int $seconds |
||
157 | * Amount of seconds when nothing to happens. |
||
158 | * |
||
159 | * @Given /^(?:|I )wait (\d+) seconds$/ |
||
160 | */ |
||
161 | public function waitSeconds($seconds) |
||
165 | |||
166 | /** |
||
167 | * @param string $selector |
||
168 | * Text or CSS. |
||
169 | * |
||
170 | * @throws \Exception |
||
171 | * |
||
172 | * @Given /^(?:|I )scroll to "([^"]*)" element$/ |
||
173 | * |
||
174 | * @javascript |
||
175 | */ |
||
176 | public function scrollToElement($selector) |
||
184 | |||
185 | /** |
||
186 | * @param string $message |
||
187 | * JS error. |
||
188 | * @param bool $negate |
||
189 | * Whether page should or should not contain the error. |
||
190 | * @param string $file |
||
191 | * File where error appears. |
||
192 | * |
||
193 | * @throws \RuntimeException |
||
194 | * @throws \Exception |
||
195 | * |
||
196 | * @example |
||
197 | * Then check that "TypeError: cell[0] is undefined" JS error appears in "misc/tabledrag.js" file |
||
198 | * |
||
199 | * @Then /^check that "([^"]*)" JS error(| not) appears in "([^"]*)" file$/ |
||
200 | * |
||
201 | * @javascript |
||
202 | */ |
||
203 | public function checkJavaScriptError($message, $negate, $file) |
||
239 | |||
240 | /** |
||
241 | * @param string $selector |
||
242 | * @param string $attribute |
||
243 | * @param string $expectedValue |
||
244 | * |
||
245 | * @throws \Exception |
||
246 | * |
||
247 | * @example |
||
248 | * Then I should see the "#table_cell" element with "colspan" attribute having "3" value |
||
249 | * |
||
250 | * @Then /^(?:|I )should see the "([^"]*)" element with "([^"]*)" attribute having "([^"]*)" value$/ |
||
251 | */ |
||
252 | public function assertElementAttribute($selector, $attribute, $expectedValue) |
||
270 | |||
271 | /** |
||
272 | * @param Scope\BeforeFeatureScope $scope |
||
273 | * Scope of the processing feature. |
||
274 | * |
||
275 | * @BeforeFeature |
||
276 | */ |
||
277 | public static function beforeFeature(Scope\BeforeFeatureScope $scope) |
||
294 | |||
295 | /** |
||
296 | * @AfterFeature |
||
297 | */ |
||
298 | public static function afterFeature() |
||
306 | |||
307 | /** |
||
308 | * @param Scope\BeforeScenarioScope $scope |
||
309 | * Scope of the processing scenario. |
||
310 | * |
||
311 | * @BeforeScenario |
||
312 | */ |
||
313 | public function beforeScenario(Scope\BeforeScenarioScope $scope) |
||
325 | |||
326 | /** |
||
327 | * Set the jQuery handlers for "start" and "finish" events of AJAX queries. |
||
328 | * In each method can be used the "waitAjaxAndAnimations" method for check |
||
329 | * that AJAX was finished. |
||
330 | * |
||
331 | * @see RawTqContext::waitAjaxAndAnimations() |
||
332 | * |
||
333 | * @BeforeScenario @javascript |
||
334 | */ |
||
335 | public function beforeScenarioJS() |
||
345 | |||
346 | /** |
||
347 | * IMPORTANT! The "BeforeStep" hook should not be tagged, because steps has no tags! |
||
348 | * |
||
349 | * @param Scope\StepScope|Scope\BeforeStepScope $scope |
||
350 | * Scope of the processing step. |
||
351 | * |
||
352 | * @BeforeStep |
||
353 | */ |
||
354 | public function beforeStep(Scope\StepScope $scope) |
||
361 | |||
362 | /** |
||
363 | * IMPORTANT! The "AfterStep" hook should not be tagged, because steps has no tags! |
||
364 | * |
||
365 | * @param Scope\StepScope|Scope\AfterStepScope $scope |
||
366 | * Scope of the processing step. |
||
367 | * |
||
368 | * @AfterStep |
||
369 | */ |
||
370 | public function afterStep(Scope\StepScope $scope) |
||
384 | } |
||
385 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: