4 * This file is part of the Mink package.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Mink\Driver;
13 use Behat\Mink\Element\NodeElement;
14 use Behat\Mink\Exception\UnsupportedDriverActionException;
15 use Behat\Mink\Session;
19 * All other drivers should extend this class for future compatibility.
21 * @author Konstantin Kudryashov <ever.zet@gmail.com>
23 abstract class CoreDriver implements DriverInterface
33 public function setSession(Session $session)
35 $this->session = $session;
41 public function start()
43 throw new UnsupportedDriverActionException('Starting the driver is not supported by %s', $this);
49 public function isStarted()
51 throw new UnsupportedDriverActionException('Checking the driver state is not supported by %s', $this);
57 public function stop()
59 throw new UnsupportedDriverActionException('Stopping the driver is not supported by %s', $this);
65 public function reset()
67 throw new UnsupportedDriverActionException('Resetting the driver is not supported by %s', $this);
73 public function visit($url)
75 throw new UnsupportedDriverActionException('Visiting an url is not supported by %s', $this);
81 public function getCurrentUrl()
83 throw new UnsupportedDriverActionException('Getting the current url is not supported by %s', $this);
89 public function getContent()
91 throw new UnsupportedDriverActionException('Getting the page content is not supported by %s', $this);
97 public function find($xpath)
101 foreach ($this->findElementXpaths($xpath) as $xpath) {
102 $elements[] = new NodeElement($xpath, $this->session);
109 * Finds elements with specified XPath query.
113 * @param string $xpath
115 * @return string[] The XPath of the matched elements
117 * @throws UnsupportedDriverActionException When operation not supported by the driver
119 protected function findElementXpaths($xpath)
121 throw new UnsupportedDriverActionException('Finding elements is not supported by %s', $this);
127 public function getTagName($xpath)
129 throw new UnsupportedDriverActionException('Getting the tag name is not supported by %s', $this);
135 public function getText($xpath)
137 throw new UnsupportedDriverActionException('Getting the element text is not supported by %s', $this);
143 public function getHtml($xpath)
145 throw new UnsupportedDriverActionException('Getting the element inner HTML is not supported by %s', $this);
151 public function getOuterHtml($xpath)
153 throw new UnsupportedDriverActionException('Getting the element outer HTML is not supported by %s', $this);
159 public function getAttribute($xpath, $name)
161 throw new UnsupportedDriverActionException('Getting the element attribute is not supported by %s', $this);
167 public function getValue($xpath)
169 throw new UnsupportedDriverActionException('Getting the field value is not supported by %s', $this);
175 public function setValue($xpath, $value)
177 throw new UnsupportedDriverActionException('Setting the field value is not supported by %s', $this);
183 public function check($xpath)
185 throw new UnsupportedDriverActionException('Checking a checkbox is not supported by %s', $this);
191 public function uncheck($xpath)
193 throw new UnsupportedDriverActionException('Unchecking a checkbox is not supported by %s', $this);
199 public function isChecked($xpath)
201 throw new UnsupportedDriverActionException('Getting the state of a checkbox is not supported by %s', $this);
207 public function selectOption($xpath, $value, $multiple = false)
209 throw new UnsupportedDriverActionException('Selecting an option is not supported by %s', $this);
215 public function click($xpath)
217 throw new UnsupportedDriverActionException('Clicking on an element is not supported by %s', $this);
223 public function attachFile($xpath, $path)
225 throw new UnsupportedDriverActionException('Attaching a file in an input is not supported by %s', $this);
231 public function reload()
233 throw new UnsupportedDriverActionException('Page reloading is not supported by %s', $this);
239 public function forward()
241 throw new UnsupportedDriverActionException('Forward action is not supported by %s', $this);
247 public function back()
249 throw new UnsupportedDriverActionException('Backward action is not supported by %s', $this);
255 public function setBasicAuth($user, $password)
257 throw new UnsupportedDriverActionException('Basic auth setup is not supported by %s', $this);
263 public function switchToWindow($name = null)
265 throw new UnsupportedDriverActionException('Windows management is not supported by %s', $this);
271 public function switchToIFrame($name = null)
273 throw new UnsupportedDriverActionException('iFrames management is not supported by %s', $this);
279 public function setRequestHeader($name, $value)
281 throw new UnsupportedDriverActionException('Request headers manipulation is not supported by %s', $this);
287 public function getResponseHeaders()
289 throw new UnsupportedDriverActionException('Response headers are not available from %s', $this);
295 public function setCookie($name, $value = null)
297 throw new UnsupportedDriverActionException('Cookies manipulation is not supported by %s', $this);
303 public function getCookie($name)
305 throw new UnsupportedDriverActionException('Cookies are not available from %s', $this);
311 public function getStatusCode()
313 throw new UnsupportedDriverActionException('Status code is not available from %s', $this);
319 public function getScreenshot()
321 throw new UnsupportedDriverActionException('Screenshots are not supported by %s', $this);
327 public function getWindowNames()
329 throw new UnsupportedDriverActionException('Listing all window names is not supported by %s', $this);
335 public function getWindowName()
337 throw new UnsupportedDriverActionException('Listing this window name is not supported by %s', $this);
343 public function doubleClick($xpath)
345 throw new UnsupportedDriverActionException('Double-clicking is not supported by %s', $this);
351 public function rightClick($xpath)
353 throw new UnsupportedDriverActionException('Right-clicking is not supported by %s', $this);
359 public function isVisible($xpath)
361 throw new UnsupportedDriverActionException('Element visibility check is not supported by %s', $this);
367 public function isSelected($xpath)
369 throw new UnsupportedDriverActionException('Element selection check is not supported by %s', $this);
375 public function mouseOver($xpath)
377 throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this);
383 public function focus($xpath)
385 throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this);
391 public function blur($xpath)
393 throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this);
399 public function keyPress($xpath, $char, $modifier = null)
401 throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this);
407 public function keyDown($xpath, $char, $modifier = null)
409 throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this);
415 public function keyUp($xpath, $char, $modifier = null)
417 throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this);
423 public function dragTo($sourceXpath, $destinationXpath)
425 throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this);
431 public function executeScript($script)
433 throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
439 public function evaluateScript($script)
441 throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
447 public function wait($timeout, $condition)
449 throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
455 public function resizeWindow($width, $height, $name = null)
457 throw new UnsupportedDriverActionException('Window resizing is not supported by %s', $this);
463 public function maximizeWindow($name = null)
465 throw new UnsupportedDriverActionException('Window maximize is not supported by %s', $this);
471 public function submitForm($xpath)
473 throw new UnsupportedDriverActionException('Form submission is not supported by %s', $this);