Version 1
[yaffs-website] / vendor / behat / mink / src / Driver / CoreDriver.php
1 <?php
2
3 /*
4  * This file is part of the Mink package.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Mink\Driver;
12
13 use Behat\Mink\Element\NodeElement;
14 use Behat\Mink\Exception\UnsupportedDriverActionException;
15 use Behat\Mink\Session;
16
17 /**
18  * Core driver.
19  * All other drivers should extend this class for future compatibility.
20  *
21  * @author Konstantin Kudryashov <ever.zet@gmail.com>
22  */
23 abstract class CoreDriver implements DriverInterface
24 {
25     /**
26      * @var Session
27      */
28     private $session;
29
30     /**
31      * {@inheritdoc}
32      */
33     public function setSession(Session $session)
34     {
35         $this->session = $session;
36     }
37
38     /**
39      * {@inheritdoc}
40      */
41     public function start()
42     {
43         throw new UnsupportedDriverActionException('Starting the driver is not supported by %s', $this);
44     }
45
46     /**
47      * {@inheritdoc}
48      */
49     public function isStarted()
50     {
51         throw new UnsupportedDriverActionException('Checking the driver state is not supported by %s', $this);
52     }
53
54     /**
55      * {@inheritdoc}
56      */
57     public function stop()
58     {
59         throw new UnsupportedDriverActionException('Stopping the driver is not supported by %s', $this);
60     }
61
62     /**
63      * {@inheritdoc}
64      */
65     public function reset()
66     {
67         throw new UnsupportedDriverActionException('Resetting the driver is not supported by %s', $this);
68     }
69
70     /**
71      * {@inheritdoc}
72      */
73     public function visit($url)
74     {
75         throw new UnsupportedDriverActionException('Visiting an url is not supported by %s', $this);
76     }
77
78     /**
79      * {@inheritdoc}
80      */
81     public function getCurrentUrl()
82     {
83         throw new UnsupportedDriverActionException('Getting the current url is not supported by %s', $this);
84     }
85
86     /**
87      * {@inheritdoc}
88      */
89     public function getContent()
90     {
91         throw new UnsupportedDriverActionException('Getting the page content is not supported by %s', $this);
92     }
93
94     /**
95      * {@inheritdoc}
96      */
97     public function find($xpath)
98     {
99         $elements = array();
100
101         foreach ($this->findElementXpaths($xpath) as $xpath) {
102             $elements[] = new NodeElement($xpath, $this->session);
103         }
104
105         return $elements;
106     }
107
108     /**
109      * Finds elements with specified XPath query.
110      *
111      * @see find()
112      *
113      * @param string $xpath
114      *
115      * @return string[] The XPath of the matched elements
116      *
117      * @throws UnsupportedDriverActionException When operation not supported by the driver
118      */
119     protected function findElementXpaths($xpath)
120     {
121         throw new UnsupportedDriverActionException('Finding elements is not supported by %s', $this);
122     }
123
124     /**
125      * {@inheritdoc}
126      */
127     public function getTagName($xpath)
128     {
129         throw new UnsupportedDriverActionException('Getting the tag name is not supported by %s', $this);
130     }
131
132     /**
133      * {@inheritdoc}
134      */
135     public function getText($xpath)
136     {
137         throw new UnsupportedDriverActionException('Getting the element text is not supported by %s', $this);
138     }
139
140     /**
141      * {@inheritdoc}
142      */
143     public function getHtml($xpath)
144     {
145         throw new UnsupportedDriverActionException('Getting the element inner HTML is not supported by %s', $this);
146     }
147
148     /**
149      * {@inheritdoc}
150      */
151     public function getOuterHtml($xpath)
152     {
153         throw new UnsupportedDriverActionException('Getting the element outer HTML is not supported by %s', $this);
154     }
155
156     /**
157      * {@inheritdoc}
158      */
159     public function getAttribute($xpath, $name)
160     {
161         throw new UnsupportedDriverActionException('Getting the element attribute is not supported by %s', $this);
162     }
163
164     /**
165      * {@inheritdoc}
166      */
167     public function getValue($xpath)
168     {
169         throw new UnsupportedDriverActionException('Getting the field value is not supported by %s', $this);
170     }
171
172     /**
173      * {@inheritdoc}
174      */
175     public function setValue($xpath, $value)
176     {
177         throw new UnsupportedDriverActionException('Setting the field value is not supported by %s', $this);
178     }
179
180     /**
181      * {@inheritdoc}
182      */
183     public function check($xpath)
184     {
185         throw new UnsupportedDriverActionException('Checking a checkbox is not supported by %s', $this);
186     }
187
188     /**
189      * {@inheritdoc}
190      */
191     public function uncheck($xpath)
192     {
193         throw new UnsupportedDriverActionException('Unchecking a checkbox is not supported by %s', $this);
194     }
195
196     /**
197      * {@inheritdoc}
198      */
199     public function isChecked($xpath)
200     {
201         throw new UnsupportedDriverActionException('Getting the state of a checkbox is not supported by %s', $this);
202     }
203
204     /**
205      * {@inheritdoc}
206      */
207     public function selectOption($xpath, $value, $multiple = false)
208     {
209         throw new UnsupportedDriverActionException('Selecting an option is not supported by %s', $this);
210     }
211
212     /**
213      * {@inheritdoc}
214      */
215     public function click($xpath)
216     {
217         throw new UnsupportedDriverActionException('Clicking on an element is not supported by %s', $this);
218     }
219
220     /**
221      * {@inheritdoc}
222      */
223     public function attachFile($xpath, $path)
224     {
225         throw new UnsupportedDriverActionException('Attaching a file in an input is not supported by %s', $this);
226     }
227
228     /**
229      * {@inheritdoc}
230      */
231     public function reload()
232     {
233         throw new UnsupportedDriverActionException('Page reloading is not supported by %s', $this);
234     }
235
236     /**
237      * {@inheritdoc}
238      */
239     public function forward()
240     {
241         throw new UnsupportedDriverActionException('Forward action is not supported by %s', $this);
242     }
243
244     /**
245      * {@inheritdoc}
246      */
247     public function back()
248     {
249         throw new UnsupportedDriverActionException('Backward action is not supported by %s', $this);
250     }
251
252     /**
253      * {@inheritdoc}
254      */
255     public function setBasicAuth($user, $password)
256     {
257         throw new UnsupportedDriverActionException('Basic auth setup is not supported by %s', $this);
258     }
259
260     /**
261      * {@inheritdoc}
262      */
263     public function switchToWindow($name = null)
264     {
265         throw new UnsupportedDriverActionException('Windows management is not supported by %s', $this);
266     }
267
268     /**
269      * {@inheritdoc}
270      */
271     public function switchToIFrame($name = null)
272     {
273         throw new UnsupportedDriverActionException('iFrames management is not supported by %s', $this);
274     }
275
276     /**
277      * {@inheritdoc}
278      */
279     public function setRequestHeader($name, $value)
280     {
281         throw new UnsupportedDriverActionException('Request headers manipulation is not supported by %s', $this);
282     }
283
284     /**
285      * {@inheritdoc}
286      */
287     public function getResponseHeaders()
288     {
289         throw new UnsupportedDriverActionException('Response headers are not available from %s', $this);
290     }
291
292     /**
293      * {@inheritdoc}
294      */
295     public function setCookie($name, $value = null)
296     {
297         throw new UnsupportedDriverActionException('Cookies manipulation is not supported by %s', $this);
298     }
299
300     /**
301      * {@inheritdoc}
302      */
303     public function getCookie($name)
304     {
305         throw new UnsupportedDriverActionException('Cookies are not available from %s', $this);
306     }
307
308     /**
309      * {@inheritdoc}
310      */
311     public function getStatusCode()
312     {
313         throw new UnsupportedDriverActionException('Status code is not available from %s', $this);
314     }
315
316     /**
317      * {@inheritdoc}
318      */
319     public function getScreenshot()
320     {
321         throw new UnsupportedDriverActionException('Screenshots are not supported by %s', $this);
322     }
323
324     /**
325      * {@inheritdoc}
326      */
327     public function getWindowNames()
328     {
329         throw new UnsupportedDriverActionException('Listing all window names is not supported by %s', $this);
330     }
331
332     /**
333      * {@inheritdoc}
334      */
335     public function getWindowName()
336     {
337         throw new UnsupportedDriverActionException('Listing this window name is not supported by %s', $this);
338     }
339
340     /**
341      * {@inheritdoc}
342      */
343     public function doubleClick($xpath)
344     {
345         throw new UnsupportedDriverActionException('Double-clicking is not supported by %s', $this);
346     }
347
348     /**
349      * {@inheritdoc}
350      */
351     public function rightClick($xpath)
352     {
353         throw new UnsupportedDriverActionException('Right-clicking is not supported by %s', $this);
354     }
355
356     /**
357      * {@inheritdoc}
358      */
359     public function isVisible($xpath)
360     {
361         throw new UnsupportedDriverActionException('Element visibility check is not supported by %s', $this);
362     }
363
364     /**
365      * {@inheritdoc}
366      */
367     public function isSelected($xpath)
368     {
369         throw new UnsupportedDriverActionException('Element selection check is not supported by %s', $this);
370     }
371
372     /**
373      * {@inheritdoc}
374      */
375     public function mouseOver($xpath)
376     {
377         throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this);
378     }
379
380     /**
381      * {@inheritdoc}
382      */
383     public function focus($xpath)
384     {
385         throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this);
386     }
387
388     /**
389      * {@inheritdoc}
390      */
391     public function blur($xpath)
392     {
393         throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this);
394     }
395
396     /**
397      * {@inheritdoc}
398      */
399     public function keyPress($xpath, $char, $modifier = null)
400     {
401         throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this);
402     }
403
404     /**
405      * {@inheritdoc}
406      */
407     public function keyDown($xpath, $char, $modifier = null)
408     {
409         throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this);
410     }
411
412     /**
413      * {@inheritdoc}
414      */
415     public function keyUp($xpath, $char, $modifier = null)
416     {
417         throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this);
418     }
419
420     /**
421      * {@inheritdoc}
422      */
423     public function dragTo($sourceXpath, $destinationXpath)
424     {
425         throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this);
426     }
427
428     /**
429      * {@inheritdoc}
430      */
431     public function executeScript($script)
432     {
433         throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
434     }
435
436     /**
437      * {@inheritdoc}
438      */
439     public function evaluateScript($script)
440     {
441         throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
442     }
443
444     /**
445      * {@inheritdoc}
446      */
447     public function wait($timeout, $condition)
448     {
449         throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
450     }
451
452     /**
453      * {@inheritdoc}
454      */
455     public function resizeWindow($width, $height, $name = null)
456     {
457         throw new UnsupportedDriverActionException('Window resizing is not supported by %s', $this);
458     }
459
460     /**
461      * {@inheritdoc}
462      */
463     public function maximizeWindow($name = null)
464     {
465         throw new UnsupportedDriverActionException('Window maximize is not supported by %s', $this);
466     }
467
468     /**
469      * {@inheritdoc}
470      */
471     public function submitForm($xpath)
472     {
473         throw new UnsupportedDriverActionException('Form submission is not supported by %s', $this);
474     }
475 }