Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Element.php

class Element

Same name in this branch
  1. 11.1.x vendor/lullabot/php-webdriver/lib/WebDriver/Element.php \WebDriver\Element
  2. 11.1.x core/lib/Drupal/Core/Config/Schema/Element.php \Drupal\Core\Config\Schema\Element
  3. 11.1.x core/lib/Drupal/Core/Render/Element.php \Drupal\Core\Render\Element
  4. 11.1.x core/modules/editor/src/Element.php \Drupal\editor\Element

Base element.

@author Konstantin Kudryashov <ever.zet@gmail.com>

Hierarchy

  • class \Behat\Mink\Element\Element implements \Behat\Mink\Element\ElementInterface

Expanded class hierarchy of Element

3 files declare their use of Element
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
18 string references to 'Element'
ckeditor5.data_types.yml in core/modules/ckeditor5/config/schema/ckeditor5.data_types.yml
core/modules/ckeditor5/config/schema/ckeditor5.data_types.yml
ckeditor5_filter_format_edit_form_submit in core/modules/ckeditor5/ckeditor5.module
Form submission handler for filter format forms.
ConfigTranslationHooks::theme in core/modules/config_translation/src/Hook/ConfigTranslationHooks.php
Implements hook_theme().
ElementInfoManager::__construct in core/lib/Drupal/Core/Render/ElementInfoManager.php
Constructs an ElementInfoManager object.
FieldUiHooks::theme in core/modules/field_ui/src/Hook/FieldUiHooks.php
Implements hook_theme().

... See full list

File

vendor/behat/mink/src/Element/Element.php, line 23

Namespace

Behat\Mink\Element
View source
abstract class Element implements ElementInterface {
    
    /**
     * @var Session
     */
    private $session;
    
    /**
     * Driver.
     *
     * @var DriverInterface
     */
    private $driver;
    
    /**
     * @var ElementFinder
     */
    private $elementFinder;
    
    /**
     * Initialize element.
     *
     * @param Session $session
     */
    public function __construct(Session $session) {
        $this->session = $session;
        $this->driver = $session->getDriver();
        $this->elementFinder = $session->getElementFinder();
    }
    
    /**
     * 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->session
            ->getSelectorsHandler();
    }
    
    /**
     * {@inheritdoc}
     */
    public function has(string $selector, $locator) {
        return null !== $this->find($selector, $locator);
    }
    
    /**
     * {@inheritdoc}
     */
    public function isValid() {
        return 1 === count($this->getDriver()
            ->find($this->getXpath()));
    }
    public function waitFor($timeout, callable $callback) {
        $start = microtime(true);
        $end = $start + $timeout;
        do {
            $result = call_user_func($callback, $this);
            if ($result) {
                break;
            }
            usleep(10000);
        } while (microtime(true) < $end);
        return $result;
    }
    
    /**
     * {@inheritdoc}
     */
    public function find(string $selector, $locator) {
        $items = $this->findAll($selector, $locator);
        return count($items) ? current($items) : null;
    }
    
    /**
     * {@inheritdoc}
     */
    public function findAll(string $selector, $locator) {
        return $this->elementFinder
            ->findAll($selector, $locator, $this->getXpath());
    }
    
    /**
     * {@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(string $type, ?string $selector = null, ?string $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

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
Element::$driver private property Driver.
Element::$elementFinder private property
Element::$session private property
Element::elementNotFound Deprecated protected function Builds an ElementNotFoundException.
Element::find public function Finds first element with specified selector inside the current element. Overrides ElementInterface::find
Element::findAll public function Finds all elements with specified selector inside the current element. Overrides ElementInterface::findAll
Element::getDriver protected function Returns element&#039;s driver.
Element::getHtml public function Returns element inner html. Overrides ElementInterface::getHtml
Element::getOuterHtml public function Returns element outer html.
Element::getSelectorsHandler Deprecated protected function Returns selectors handler.
Element::getSession Deprecated public function Returns element session. Overrides ElementInterface::getSession
Element::getText public function Returns element text (inside tag). Overrides ElementInterface::getText
Element::has public function Checks whether element with specified selector exists inside the current element. Overrides ElementInterface::has
Element::isValid public function Checks if an element still exists in the DOM. Overrides ElementInterface::isValid
Element::waitFor public function Waits for a value to be available and returns it. Overrides ElementInterface::waitFor
Element::__construct public function Initialize element. 1
ElementInterface::getXpath public function Returns XPath for handled element. 2

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal