Element.php in Zircon Profile 8
File
vendor/behat/mink/src/Element/Element.php
View source
<?php
namespace Behat\Mink\Element;
use Behat\Mink\Driver\DriverInterface;
use Behat\Mink\Exception\ElementNotFoundException;
use Behat\Mink\Selector\SelectorsHandler;
use Behat\Mink\Selector\Xpath\Manipulator;
use Behat\Mink\Session;
abstract class Element implements ElementInterface {
private $session;
private $driver;
private $selectorsHandler;
private $xpathManipulator;
public function __construct(Session $session) {
$this->xpathManipulator = new Manipulator();
$this->session = $session;
$this->driver = $session
->getDriver();
$this->selectorsHandler = $session
->getSelectorsHandler();
}
public function getSession() {
@trigger_error(sprintf('The method %s is deprecated as of 1.6 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED);
return $this->session;
}
protected function getDriver() {
return $this->driver;
}
protected function getSelectorsHandler() {
@trigger_error(sprintf('The method %s is deprecated as of 1.7 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED);
return $this->selectorsHandler;
}
public function has($selector, $locator) {
return null !== $this
->find($selector, $locator);
}
public function isValid() {
return 1 === count($this
->getDriver()
->find($this
->getXpath()));
}
public function waitFor($timeout, $callback) {
if (!is_callable($callback)) {
throw new \InvalidArgumentException('Given callback is not a valid callable');
}
$start = microtime(true);
$end = $start + $timeout;
do {
$result = call_user_func($callback, $this);
if ($result) {
break;
}
usleep(100000);
} while (microtime(true) < $end);
return $result;
}
public function find($selector, $locator) {
$items = $this
->findAll($selector, $locator);
return count($items) ? current($items) : null;
}
public function findAll($selector, $locator) {
if ('named' === $selector) {
$items = $this
->findAll('named_exact', $locator);
if (empty($items)) {
$items = $this
->findAll('named_partial', $locator);
}
return $items;
}
$xpath = $this->selectorsHandler
->selectorToXpath($selector, $locator);
$xpath = $this->xpathManipulator
->prepend($xpath, $this
->getXpath());
return $this
->getDriver()
->find($xpath);
}
public function getText() {
return $this
->getDriver()
->getText($this
->getXpath());
}
public function getHtml() {
return $this
->getDriver()
->getHtml($this
->getXpath());
}
public function getOuterHtml() {
return $this
->getDriver()
->getOuterHtml($this
->getXpath());
}
protected function elementNotFound($type, $selector = null, $locator = null) {
@trigger_error(sprintf('The method %s is deprecated as of 1.7 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED);
return new ElementNotFoundException($this->driver, $type, $selector, $locator);
}
}