You are here

public function DurationFieldBrowserTestBase::selectRadio in Duration Field 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/DurationFieldBrowserTestBase.php \Drupal\Tests\duration_field\Functional\DurationFieldBrowserTestBase::selectRadio()
  2. 3.0.x tests/src/Functional/DurationFieldBrowserTestBase.php \Drupal\Tests\duration_field\Functional\DurationFieldBrowserTestBase::selectRadio()

Selects a given radio element.

File

tests/src/Functional/DurationFieldBrowserTestBase.php, line 43

Class

DurationFieldBrowserTestBase
Base class that provides some helper functions for functional tests.

Namespace

Drupal\Tests\duration_field\Functional

Code

public function selectRadio($htmlID) {
  if (preg_match('/^#/', $htmlID)) {
    $htmlID = substr($htmlID, 1);
  }
  $radio = $this
    ->getSession()
    ->getPage()
    ->findField($htmlID);
  $name = $radio
    ->getAttribute('name');
  $option = $radio
    ->getAttribute('value');
  $this
    ->getSession()
    ->getPage()
    ->selectFieldOption($name, $option);
}