1 | <?php |
||
14 | class TqContext extends RawTqContext |
||
15 | { |
||
16 | use LogicalAssertion; |
||
17 | |||
18 | /** |
||
19 | * The name and working element of main window. |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | private $mainWindow = []; |
||
24 | /** |
||
25 | * @var Database |
||
26 | */ |
||
27 | private static $database; |
||
28 | |||
29 | /** |
||
30 | * Supports switching between the two windows only. |
||
31 | * |
||
32 | * @Given /^(?:|I )switch to opened window$/ |
||
33 | * @Then /^(?:|I )switch back to main window$/ |
||
34 | */ |
||
35 | public function iSwitchToWindow() |
||
55 | |||
56 | /** |
||
57 | * @Given /^(?:|I )switch to CKFinder window$/ |
||
58 | * |
||
59 | * @javascript |
||
60 | */ |
||
61 | public function switchToCKFinderWindow() |
||
70 | |||
71 | /** |
||
72 | * @param string $name |
||
73 | * An iframe name (null for switching back). |
||
74 | * |
||
75 | * @Given /^(?:|I )switch to an iframe "([^"]*)"$/ |
||
76 | * @Then /^(?:|I )switch back from an iframe$/ |
||
77 | */ |
||
78 | public function iSwitchToAnIframe($name = null) |
||
82 | |||
83 | /** |
||
84 | * Open the page with specified resolution. |
||
85 | * |
||
86 | * @param string $width_height |
||
87 | * String that satisfy the condition "<WIDTH>x<HEIGHT>". |
||
88 | * |
||
89 | * @example |
||
90 | * Given I should use the "1280x800" resolution |
||
91 | * |
||
92 | * @Given /^(?:|I should )use the "([^"]*)" screen resolution$/ |
||
93 | */ |
||
94 | public function useScreenResolution($width_height) |
||
100 | |||
101 | /** |
||
102 | * @param string $action |
||
103 | * The next actions can be: "press", "click", "double click" and "right click". |
||
104 | * @param string $selector |
||
105 | * CSS, inaccurate text or selector name from behat.yml can be used. |
||
106 | * |
||
107 | * @throws \WebDriver\Exception\NoSuchElement |
||
108 | * When element was not found. |
||
109 | * |
||
110 | * @Given /^(?:|I )((?:|(?:double|right) )click|press) on "([^"]*)"$/ |
||
111 | */ |
||
112 | public function pressElement($action, $selector) |
||
120 | |||
121 | /** |
||
122 | * @Given /^(?:|I )wait until AJAX is finished$/ |
||
123 | * |
||
124 | * @javascript |
||
125 | */ |
||
126 | public function waitUntilAjaxIsFinished() |
||
130 | |||
131 | /** |
||
132 | * @param string $selector |
||
133 | * CSS selector or region name. |
||
134 | * |
||
135 | * @Then /^(?:|I )work with elements in "([^"]*)"(?:| region)$/ |
||
136 | */ |
||
137 | public function workWithElementsInRegion($selector) |
||
147 | |||
148 | /** |
||
149 | * @Then /^(?:|I )checkout to whole page$/ |
||
150 | */ |
||
151 | public function unsetWorkingElementScope() |
||
155 | |||
156 | /** |
||
157 | * @param int $seconds |
||
158 | * Amount of seconds when nothing to happens. |
||
159 | * |
||
160 | * @Given /^(?:|I )wait (\d+) seconds$/ |
||
161 | */ |
||
162 | public function waitSeconds($seconds) |
||
166 | |||
167 | /** |
||
168 | * @param string $selector |
||
169 | * Text or CSS. |
||
170 | * |
||
171 | * @throws \Exception |
||
172 | * |
||
173 | * @Given /^(?:|I )scroll to "([^"]*)" element$/ |
||
174 | * |
||
175 | * @javascript |
||
176 | */ |
||
177 | public function scrollToElement($selector) |
||
185 | |||
186 | /** |
||
187 | * @param string $message |
||
188 | * JS error. |
||
189 | * @param bool $negate |
||
190 | * Whether page should or should not contain the error. |
||
191 | * @param string $file |
||
192 | * File where error appears. |
||
193 | * |
||
194 | * @throws \RuntimeException |
||
195 | * @throws \Exception |
||
196 | * |
||
197 | * @example |
||
198 | * Then check that "TypeError: cell[0] is undefined" JS error appears in "misc/tabledrag.js" file |
||
199 | * Then check that "TypeError: cell[0] is undefined" JS error appears on the page |
||
200 | * |
||
201 | * @Then /^check that "([^"]*)" JS error(| not) appears (?:in "([^"]*)" file|on the page)$/ |
||
202 | * |
||
203 | * @javascript |
||
204 | */ |
||
205 | public function checkJavaScriptError($message, $negate, $file = '') |
||
237 | |||
238 | /** |
||
239 | * @param string $selector |
||
240 | * @param string $attribute |
||
241 | * @param string $expectedValue |
||
242 | * |
||
243 | * @throws \Exception |
||
244 | * |
||
245 | * @example |
||
246 | * Then I should see the "#table_cell" element with "colspan" attribute having "3" value |
||
247 | * |
||
248 | * @Then /^(?:|I )should see the "([^"]*)" element with "([^"]*)" attribute having "([^"]*)" value$/ |
||
249 | */ |
||
250 | 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) |
||
283 | |||
284 | /** |
||
285 | * @AfterFeature |
||
286 | */ |
||
287 | public static function afterFeature() |
||
295 | |||
296 | /** |
||
297 | * @param Scope\BeforeScenarioScope $scope |
||
298 | * Scope of the processing scenario. |
||
299 | * |
||
300 | * @BeforeScenario |
||
301 | */ |
||
302 | public function beforeScenario(Scope\BeforeScenarioScope $scope) |
||
311 | |||
312 | /** |
||
313 | * Track XMLHttpRequest starts and finishes using pure JavaScript. |
||
314 | * |
||
315 | * @see RawTqContext::waitAjaxAndAnimations() |
||
316 | * |
||
317 | * @BeforeScenario @javascript |
||
318 | */ |
||
319 | public function beforeScenarioJS() |
||
323 | |||
324 | /** |
||
325 | * IMPORTANT! The "BeforeStep" hook should not be tagged, because steps has no tags! |
||
326 | * |
||
327 | * @param Scope\StepScope|Scope\BeforeStepScope $scope |
||
328 | * Scope of the processing step. |
||
329 | * |
||
330 | * @BeforeStep |
||
331 | */ |
||
332 | public function beforeStep(Scope\StepScope $scope) |
||
338 | |||
339 | /** |
||
340 | * IMPORTANT! The "AfterStep" hook should not be tagged, because steps has no tags! |
||
341 | * |
||
342 | * @param Scope\StepScope|Scope\AfterStepScope $scope |
||
343 | * Scope of the processing step. |
||
344 | * |
||
345 | * @AfterStep |
||
346 | */ |
||
347 | public function afterStep(Scope\StepScope $scope) |
||
361 | } |
||
362 |
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: