ElementNotFoundException example


  public function assertVisibleInViewport($selector_type$selector$corner = FALSE, $message = 'Element is not visible in the viewport.') {
    $node = $this->session->getPage()->find($selector_type$selector);
    if ($node === NULL) {
      if (is_array($selector)) {
        $selector = implode(' ', $selector);
      }
      throw new ElementNotFoundException($this->session->getDriver(), 'element', $selector_type$selector);
    }

    // Check if the node is visible on the page, which is a prerequisite of     // being visible in the viewport.     if (!$node->isVisible()) {
      throw new ElementHtmlException($message$this->session->getDriver()$node);
    }

    $result = $this->checkNodeVisibilityInViewport($node$corner);

    if (!$result) {
      

  public function buttonExists($button, TraversableElement $container = NULL) {
    $container = $container ?: $this->session->getPage();
    $node = $container->findButton($button);

    if ($node === NULL) {
      throw new ElementNotFoundException($this->session->getDriver(), 'button', 'id|name|label|value', $button);
    }

    return $node;
  }

  /** * Checks that the specific button does NOT exist 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. * * @throws \Behat\Mink\Exception\ExpectationException * When the button exists. */

  protected function helperButtonHasLabel($id$expected_label$message = 'Label has the expected value: %label.') {
    $xpath = $this->assertSession()->buildXPathQuery('//button[@id=:value]|//input[@id=:value]', [':value' => $id]);
    $field = $this->getSession()->getPage()->find('xpath', $xpath);

    if (empty($field)) {
      throw new ElementNotFoundException($this->getSession()->getDriver(), 'form field', 'id', $field);
    }

    $this->assertEquals($expected_label$field->getValue());
  }

  /** * Executes a view. * * @param \Drupal\views\ViewExecutable $view * The view object. * @param array $args * (optional) An array of the view arguments to use for the view. */
Home | Imprint | This part of the site doesn't use cookies.