You are here

class WebAssert in Zircon Profile 8

Same name in this branch
  1. 8 vendor/behat/mink/src/WebAssert.php \Behat\Mink\WebAssert
  2. 8 core/modules/simpletest/src/WebAssert.php \Drupal\simpletest\WebAssert
Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/WebAssert.php \Drupal\simpletest\WebAssert

Defines a class with methods for asserting presence of elements during tests.

Hierarchy

Expanded class hierarchy of WebAssert

File

core/modules/simpletest/src/WebAssert.php, line 17
Contains \Drupal\simpletest\WebAssert.

Namespace

Drupal\simpletest
View source
class WebAssert extends MinkWebAssert {

  /**
   * Checks that specific button exists on the current page.
   *
   * @param string $button
   *   One of id|name|label|value for the button.
   * @param \Behat\Mink\Element\TraversableElement $container
   *   (optional) The document to check against. Defaults to the current page.
   *
   * @return \Behat\Mink\Element\NodeElement
   *   The matching element.
   *
   * @throws \Behat\Mink\Exception\ElementNotFoundException
   *   When the element doesn't exist.
   */
  public function buttonExists($button, TraversableElement $container = NULL) {
    $container = $container ?: $this->session
      ->getPage();
    $node = $container
      ->findButton($button);
    if ($node === NULL) {
      throw new ElementNotFoundException($this->session, 'button', 'id|name|label|value', $button);
    }
    return $node;
  }

  /**
   * Checks that specific select field exists on the current page.
   *
   * @param string $select
   *   One of id|name|label|value for the select field.
   * @param \Behat\Mink\Element\TraversableElement $container
   *   (optional) The document to check against. Defaults to the current page.
   *
   * @return \Behat\Mink\Element\NodeElement
   *   The matching element
   *
   * @throws \Behat\Mink\Exception\ElementNotFoundException
   *   When the element doesn't exist.
   */
  public function selectExists($select, TraversableElement $container = NULL) {
    $container = $container ?: $this->session
      ->getPage();
    $node = $container
      ->find('named', array(
      'select',
      $this->session
        ->getSelectorsHandler()
        ->xpathLiteral($select),
    ));
    if ($node === NULL) {
      throw new ElementNotFoundException($this->session, 'select', 'id|name|label|value', $select);
    }
    return $node;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WebAssert::$session protected property
WebAssert::addressEquals public function Checks that current session address is equals to provided one.
WebAssert::addressMatches public function Checks that current session address matches regex.
WebAssert::addressNotEquals public function Checks that current session address is not equals to provided one.
WebAssert::assert private function Asserts a condition.
WebAssert::assertElement private function Asserts a condition on an element.
WebAssert::assertElementText private function Asserts a condition involving the text of an element.
WebAssert::assertResponseText private function Asserts a condition involving the response text.
WebAssert::buttonExists public function Checks that specific button exists on the current page.
WebAssert::checkboxChecked public function Checks that specific checkbox is checked.
WebAssert::checkboxNotChecked public function Checks that specific checkbox is unchecked.
WebAssert::cleanUrl protected function Trims scriptname from the URL.
WebAssert::cookieEquals public function Checks that specified cookie exists and its value equals to a given one.
WebAssert::cookieExists public function Checks that specified cookie exists.
WebAssert::elementAttributeContains public function Checks that an attribute of a specific elements contains text.
WebAssert::elementAttributeExists public function Checks that an attribute exists in an element.
WebAssert::elementAttributeNotContains public function Checks that an attribute of a specific elements does not contain text.
WebAssert::elementContains public function Checks that specific element contains HTML.
WebAssert::elementExists public function Checks that specific element exists on the current page.
WebAssert::elementNotContains public function Checks that specific element does not contains HTML.
WebAssert::elementNotExists public function Checks that specific element does not exists on the current page.
WebAssert::elementsCount public function Checks that there is specified number of specific elements on the page.
WebAssert::elementTextContains public function Checks that specific element contains text.
WebAssert::elementTextNotContains public function Checks that specific element does not contains text.
WebAssert::fieldExists public function Checks that specific field exists on the current page.
WebAssert::fieldNotExists public function Checks that specific field does not exists on the current page.
WebAssert::fieldValueEquals public function Checks that specific field have provided value.
WebAssert::fieldValueNotEquals public function Checks that specific field have provided value.
WebAssert::getCurrentUrlPath protected function Gets current url of the page.
WebAssert::getMatchingElementRepresentation private function
WebAssert::pageTextContains public function Checks that current page contains text.
WebAssert::pageTextMatches public function Checks that current page text matches regex.
WebAssert::pageTextNotContains public function Checks that current page does not contains text.
WebAssert::pageTextNotMatches public function Checks that current page text does not matches regex.
WebAssert::responseContains public function Checks that page HTML (response content) contains text.
WebAssert::responseHeaderContains public function Checks that current response header contains value.
WebAssert::responseHeaderEquals public function Checks that current response header equals value.
WebAssert::responseHeaderMatches public function Checks that current response header matches regex.
WebAssert::responseHeaderNotContains public function Checks that current response header does not contain value.
WebAssert::responseHeaderNotEquals public function Checks that current response header does not equal value.
WebAssert::responseHeaderNotMatches public function Checks that current response header does not match regex.
WebAssert::responseMatches public function Checks that page HTML (response content) matches regex.
WebAssert::responseNotContains public function Checks that page HTML (response content) does not contains text.
WebAssert::responseNotMatches public function Checks that page HTML (response content) does not matches regex.
WebAssert::selectExists public function Checks that specific select field exists on the current page.
WebAssert::statusCodeEquals public function Checks that current response code equals to provided one.
WebAssert::statusCodeNotEquals public function Checks that current response code not equals to provided one.
WebAssert::__construct public function Initializes assertion engine.