annotate vendor/behat/mink/src/Driver/CoreDriver.php @ 19:fa3358dc1485 tip

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