Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Behat\Mink\Driver; Chris@0: Chris@0: use Behat\Mink\Element\NodeElement; Chris@0: use Behat\Mink\Exception\UnsupportedDriverActionException; Chris@0: use Behat\Mink\Session; Chris@0: Chris@0: /** Chris@0: * Core driver. Chris@0: * All other drivers should extend this class for future compatibility. Chris@0: * Chris@0: * @author Konstantin Kudryashov Chris@0: */ Chris@0: abstract class CoreDriver implements DriverInterface Chris@0: { Chris@0: /** Chris@0: * @var Session Chris@0: */ Chris@0: private $session; Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setSession(Session $session) Chris@0: { Chris@0: $this->session = $session; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function start() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Starting the driver is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isStarted() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Checking the driver state is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function stop() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Stopping the driver is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function reset() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Resetting the driver is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function visit($url) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Visiting an url is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getCurrentUrl() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Getting the current url is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getContent() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Getting the page content is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function find($xpath) Chris@0: { Chris@0: $elements = array(); Chris@0: Chris@0: foreach ($this->findElementXpaths($xpath) as $xpath) { Chris@0: $elements[] = new NodeElement($xpath, $this->session); Chris@0: } Chris@0: Chris@0: return $elements; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Finds elements with specified XPath query. Chris@0: * Chris@0: * @see find() Chris@0: * Chris@0: * @param string $xpath Chris@0: * Chris@0: * @return string[] The XPath of the matched elements Chris@0: * Chris@0: * @throws UnsupportedDriverActionException When operation not supported by the driver Chris@0: */ Chris@0: protected function findElementXpaths($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Finding elements is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getTagName($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Getting the tag name is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getText($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Getting the element text is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getHtml($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Getting the element inner HTML is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getOuterHtml($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Getting the element outer HTML is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getAttribute($xpath, $name) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Getting the element attribute is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getValue($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Getting the field value is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setValue($xpath, $value) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Setting the field value is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function check($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Checking a checkbox is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function uncheck($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Unchecking a checkbox is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isChecked($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Getting the state of a checkbox is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function selectOption($xpath, $value, $multiple = false) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Selecting an option is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function click($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Clicking on an element is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function attachFile($xpath, $path) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Attaching a file in an input is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function reload() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Page reloading is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function forward() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Forward action is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function back() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Backward action is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setBasicAuth($user, $password) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Basic auth setup is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function switchToWindow($name = null) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Windows management is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function switchToIFrame($name = null) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('iFrames management is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setRequestHeader($name, $value) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Request headers manipulation is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getResponseHeaders() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Response headers are not available from %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setCookie($name, $value = null) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Cookies manipulation is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getCookie($name) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Cookies are not available from %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getStatusCode() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Status code is not available from %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getScreenshot() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Screenshots are not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getWindowNames() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Listing all window names is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getWindowName() Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Listing this window name is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function doubleClick($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Double-clicking is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function rightClick($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Right-clicking is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isVisible($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Element visibility check is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isSelected($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Element selection check is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function mouseOver($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function focus($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function blur($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function keyPress($xpath, $char, $modifier = null) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function keyDown($xpath, $char, $modifier = null) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function keyUp($xpath, $char, $modifier = null) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function dragTo($sourceXpath, $destinationXpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Mouse manipulations are not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function executeScript($script) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('JS is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function evaluateScript($script) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('JS is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function wait($timeout, $condition) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('JS is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function resizeWindow($width, $height, $name = null) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Window resizing is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function maximizeWindow($name = null) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Window maximize is not supported by %s', $this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function submitForm($xpath) Chris@0: { Chris@0: throw new UnsupportedDriverActionException('Form submission is not supported by %s', $this); Chris@0: } Chris@0: }