You are here

trait BrowserTestHelpersTrait in Typed Data API enhancements 8

Provides some helpers for BrowserTestBase.

Hierarchy

1 file declares its use of BrowserTestHelpersTrait
FormWidgetBrowserTestBase.php in tests/src/Functional/TypedDataFormWidget/FormWidgetBrowserTestBase.php

File

tests/src/Traits/BrowserTestHelpersTrait.php, line 8

Namespace

Drupal\Tests\typed_data\Traits
View source
trait BrowserTestHelpersTrait {

  /**
   * Finds link with specified locator.
   *
   * @param string $locator
   *   Link id, title, text or image alt.
   *
   * @return \Behat\Mink\Element\NodeElement|null
   *   The link node element.
   */
  public function findLink($locator) {
    return $this
      ->getSession()
      ->getPage()
      ->findLink($locator);
  }

  /**
   * Finds field (input, textarea, select) with specified locator.
   *
   * @param string $locator
   *   Input id, name or label.
   *
   * @return \Behat\Mink\Element\NodeElement|null
   *   The input field element.
   */
  public function findField($locator) {
    return $this
      ->getSession()
      ->getPage()
      ->findField($locator);
  }

  /**
   * Finds button with specified locator.
   *
   * @param string $locator
   *   Button id, value or alt.
   *
   * @return \Behat\Mink\Element\NodeElement|null
   *   The button node element.
   */
  public function findButton($locator) {
    return $this
      ->getSession()
      ->getPage()
      ->findButton($locator);
  }

  /**
   * Presses button with specified locator.
   *
   * @param string $locator
   *   Button id, value or alt.
   *
   * @throws \Behat\Mink\Exception\ElementNotFoundException
   */
  public function pressButton($locator) {
    $this
      ->getSession()
      ->getPage()
      ->pressButton($locator);
  }

  /**
   * Fills in field (input, textarea, select) with specified locator.
   *
   * @param string $locator
   *   Input id, name or label.
   * @param string $value
   *   Value.
   *
   * @throws \Behat\Mink\Exception\ElementNotFoundException
   *
   * @see \Behat\Mink\Element\NodeElement::setValue
   */
  public function fillField($locator, $value) {
    $this
      ->getSession()
      ->getPage()
      ->fillField($locator, $value);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BrowserTestHelpersTrait::fillField public function Fills in field (input, textarea, select) with specified locator.
BrowserTestHelpersTrait::findButton public function Finds button with specified locator.
BrowserTestHelpersTrait::findField public function Finds field (input, textarea, select) with specified locator.
BrowserTestHelpersTrait::findLink public function Finds link with specified locator.
BrowserTestHelpersTrait::pressButton public function Presses button with specified locator.