public function FeatureContext::clickRadioButton in Open Social 8.4
Same name and namespace in other branches
- 8.9 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
- 8.3 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
- 8.5 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
- 8.6 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
- 8.7 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
- 8.8 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
- 10.3.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
- 10.0.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
- 10.1.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
- 10.2.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::clickRadioButton()
@When I click radio button :label with the id :id @When I click radio button :label
1 call to FeatureContext::clickRadioButton()
- FeatureContext::iSelectPostVisibility in tests/
behat/ features/ bootstrap/ FeatureContext.php - @When I select post visibility :visibility
File
- tests/
behat/ features/ bootstrap/ FeatureContext.php, line 360
Class
- FeatureContext
- Defines application features from the specific context.
Namespace
Drupal\social\BehatCode
public function clickRadioButton($label = '', $id = '') {
$session = $this
->getSession();
$session
->executeScript("var inputs = document.getElementsByTagName('input');\n for(var i = 0; i < inputs.length; i++) {\n inputs[i].style.opacity = 1;\n inputs[i].style.left = 0;\n inputs[i].style.visibility = 'visible';\n inputs[i].style.position = 'relative';\n }\n ");
$element = $session
->getPage();
$radiobutton = $id ? $element
->findById($id) : $element
->find('named', array(
'radio',
$this
->getSession()
->getSelectorsHandler()
->xpathLiteral($label),
));
if ($radiobutton === NULL) {
throw new \Exception(sprintf('The radio button with "%s" was not found on the page %s', $id ? $id : $label, $this
->getSession()
->getCurrentUrl()));
}
$value = $radiobutton
->getAttribute('value');
$labelonpage = $radiobutton
->getParent()
->getText();
if ($label !== '' && $label != $labelonpage) {
throw new \Exception(sprintf("Button with id '%s' has label '%s' instead of '%s' on the page %s", $id, $labelonpage, $label, $this
->getSession()
->getCurrentUrl()));
}
$radiobutton
->selectOption($value, FALSE);
}