abstract class Element in Zircon Profile 8
Same name in this branch
- 8 core/modules/editor/src/Element.php \Drupal\editor\Element
- 8 vendor/behat/mink/src/Element/Element.php \Behat\Mink\Element\Element
- 8 core/lib/Drupal/Core/Render/Element.php \Drupal\Core\Render\Element
- 8 core/lib/Drupal/Core/Config/Schema/Element.php \Drupal\Core\Config\Schema\Element
Same name and namespace in other branches
- 8.0 vendor/behat/mink/src/Element/Element.php \Behat\Mink\Element\Element
Base element.
@author Konstantin Kudryashov <ever.zet@gmail.com>
Hierarchy
- class \Behat\Mink\Element\Element implements ElementInterface
Expanded class hierarchy of Element
4 files declare their use of Element
- BrowserTestBase.php in core/
modules/ simpletest/ src/ BrowserTestBase.php - Contains \Drupal\simpletest\BrowserTestBase.
- ElementException.php in vendor/
behat/ mink/ src/ Exception/ ElementException.php - ElementHtmlException.php in vendor/
behat/ mink/ src/ Exception/ ElementHtmlException.php - WebAssert.php in vendor/
behat/ mink/ src/ WebAssert.php
2 string references to 'Element'
- ElementInfoManager::__construct in core/
lib/ Drupal/ Core/ Render/ ElementInfoManager.php - Constructs a ElementInfoManager object.
- views.schema.yml in core/
modules/ views/ config/ schema/ views.schema.yml - core/modules/views/config/schema/views.schema.yml
File
- vendor/
behat/ mink/ src/ Element/ Element.php, line 24
Namespace
Behat\Mink\ElementView source
abstract class Element implements ElementInterface {
/**
* @var Session
*/
private $session;
/**
* Driver.
*
* @var DriverInterface
*/
private $driver;
/**
* @var SelectorsHandler
*/
private $selectorsHandler;
/**
* @var Manipulator
*/
private $xpathManipulator;
/**
* Initialize element.
*
* @param Session $session
*/
public function __construct(Session $session) {
$this->xpathManipulator = new Manipulator();
$this->session = $session;
$this->driver = $session
->getDriver();
$this->selectorsHandler = $session
->getSelectorsHandler();
}
/**
* Returns element session.
*
* @return Session
*
* @deprecated Accessing the session from the element is deprecated as of 1.6 and will be impossible in 2.0.
*/
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;
}
/**
* Returns element's driver.
*
* @return DriverInterface
*/
protected function getDriver() {
return $this->driver;
}
/**
* Returns selectors handler.
*
* @return SelectorsHandler
*
* @deprecated Accessing the selectors handler in the element is deprecated as of 1.7 and will be impossible in 2.0.
*/
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;
}
/**
* {@inheritdoc}
*/
public function has($selector, $locator) {
return null !== $this
->find($selector, $locator);
}
/**
* {@inheritdoc}
*/
public function isValid() {
return 1 === count($this
->getDriver()
->find($this
->getXpath()));
}
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public function find($selector, $locator) {
$items = $this
->findAll($selector, $locator);
return count($items) ? current($items) : null;
}
/**
* {@inheritdoc}
*/
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);
}
/**
* {@inheritdoc}
*/
public function getText() {
return $this
->getDriver()
->getText($this
->getXpath());
}
/**
* {@inheritdoc}
*/
public function getHtml() {
return $this
->getDriver()
->getHtml($this
->getXpath());
}
/**
* Returns element outer html.
*
* @return string
*/
public function getOuterHtml() {
return $this
->getDriver()
->getOuterHtml($this
->getXpath());
}
/**
* Builds an ElementNotFoundException.
*
* @param string $type
* @param string|null $selector
* @param string|null $locator
*
* @return ElementNotFoundException
*
* @deprecated as of 1.7, to be removed in 2.0
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Element:: |
private | property | Driver. | |
Element:: |
private | property | ||
Element:: |
private | property | ||
Element:: |
private | property | ||
Element:: |
protected | function | Builds an ElementNotFoundException. | |
Element:: |
public | function |
Finds first element with specified selector inside the current element. Overrides ElementInterface:: |
|
Element:: |
public | function |
Finds all elements with specified selector inside the current element. Overrides ElementInterface:: |
|
Element:: |
protected | function | Returns element's driver. | |
Element:: |
public | function |
Returns element inner html. Overrides ElementInterface:: |
|
Element:: |
public | function | Returns element outer html. | |
Element:: |
protected | function | Returns selectors handler. | |
Element:: |
public | function |
Returns element session. Overrides ElementInterface:: |
|
Element:: |
public | function |
Returns element text (inside tag). Overrides ElementInterface:: |
|
Element:: |
public | function |
Checks whether element with specified selector exists inside the current element. Overrides ElementInterface:: |
|
Element:: |
public | function |
Checks if an element still exists in the DOM. Overrides ElementInterface:: |
|
Element:: |
public | function |
Waits for an element(-s) to appear and returns it. Overrides ElementInterface:: |
|
Element:: |
public | function | Initialize element. | 1 |
ElementInterface:: |
public | function | Returns XPath for handled element. | 2 |