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) |
||
140 | |||
141 | /** |
||
142 | * @Then /^(?:|I )checkout to whole page$/ |
||
143 | */ |
||
144 | public function unsetWorkingElementScope() |
||
148 | |||
149 | /** |
||
150 | * @param int $seconds |
||
151 | * Amount of seconds when nothing to happens. |
||
152 | * |
||
153 | * @Given /^(?:|I )wait (\d+) seconds$/ |
||
154 | */ |
||
155 | public function waitSeconds($seconds) |
||
159 | |||
160 | /** |
||
161 | * @param string $selector |
||
162 | * Text or CSS. |
||
163 | * |
||
164 | * @throws \Exception |
||
165 | * |
||
166 | * @Given /^(?:|I )scroll to "([^"]*)" element$/ |
||
167 | * |
||
168 | * @javascript |
||
169 | */ |
||
170 | public function scrollToElement($selector) |
||
178 | |||
179 | /** |
||
180 | * @param string $message |
||
181 | * JS error. |
||
182 | * @param bool $negate |
||
183 | * Whether page should or should not contain the error. |
||
184 | * @param string $file |
||
185 | * File where error appears. |
||
186 | * |
||
187 | * @throws \RuntimeException |
||
188 | * @throws \Exception |
||
189 | * |
||
190 | * @example |
||
191 | * Then check that "TypeError: cell[0] is undefined" JS error appears in "misc/tabledrag.js" file |
||
192 | * |
||
193 | * @Then /^check that "([^"]*)" JS error(| not) appears in "([^"]*)" file$/ |
||
194 | * |
||
195 | * @javascript |
||
196 | */ |
||
197 | public function checkJavaScriptError($message, $negate, $file) |
||
233 | |||
234 | /** |
||
235 | * @param string $selector |
||
236 | * @param string $attribute |
||
237 | * @param string $expectedValue |
||
238 | * |
||
239 | * @throws \Exception |
||
240 | * |
||
241 | * @example |
||
242 | * Then I should see the "#table_cell" element with "colspan" attribute having "3" value |
||
243 | * |
||
244 | * @Then /^(?:|I )should see the "([^"]*)" element with "([^"]*)" attribute having "([^"]*)" value$/ |
||
245 | */ |
||
246 | public function assertElementAttribute($selector, $attribute, $expectedValue) |
||
264 | |||
265 | /** |
||
266 | * @param Scope\BeforeFeatureScope $scope |
||
267 | * Scope of the processing feature. |
||
268 | * |
||
269 | * @BeforeFeature |
||
270 | */ |
||
271 | public static function beforeFeature(Scope\BeforeFeatureScope $scope) |
||
288 | |||
289 | /** |
||
290 | * @AfterFeature |
||
291 | */ |
||
292 | public static function afterFeature() |
||
300 | |||
301 | /** |
||
302 | * @param Scope\BeforeScenarioScope $scope |
||
303 | * Scope of the processing scenario. |
||
304 | * |
||
305 | * @BeforeScenario |
||
306 | */ |
||
307 | public function beforeScenario(Scope\BeforeScenarioScope $scope) |
||
319 | |||
320 | /** |
||
321 | * Set the jQuery handlers for "start" and "finish" events of AJAX queries. |
||
322 | * In each method can be used the "waitAjaxAndAnimations" method for check |
||
323 | * that AJAX was finished. |
||
324 | * |
||
325 | * @see RawTqContext::waitAjaxAndAnimations() |
||
326 | * |
||
327 | * @BeforeScenario @javascript |
||
328 | */ |
||
329 | public function beforeScenarioJS() |
||
339 | |||
340 | /** |
||
341 | * IMPORTANT! The "BeforeStep" hook should not be tagged, because steps has no tags! |
||
342 | * |
||
343 | * @param Scope\StepScope|Scope\BeforeStepScope $scope |
||
344 | * Scope of the processing step. |
||
345 | * |
||
346 | * @BeforeStep |
||
347 | */ |
||
348 | public function beforeStep(Scope\StepScope $scope) |
||
355 | |||
356 | /** |
||
357 | * IMPORTANT! The "AfterStep" hook should not be tagged, because steps has no tags! |
||
358 | * |
||
359 | * @param Scope\StepScope|Scope\AfterStepScope $scope |
||
360 | * Scope of the processing step. |
||
361 | * |
||
362 | * @AfterStep |
||
363 | */ |
||
364 | public function afterStep(Scope\StepScope $scope) |
||
378 | } |
||
379 |
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: