public function TestSubContext::assertSeeRadioById in Panopoly 7
Same name and namespace in other branches
- 8.2 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::assertSeeRadioById()
@Then I should see the radio button :field with the id :id @Then I should see the radio button :field
File
- modules/
panopoly/ panopoly_test/ behat/ steps/ panopoly_test.behat.inc, line 972 - Provide Behat step-definitions for generic Panopoly tests.
Class
Code
public function assertSeeRadioById($field, $id = FALSE) {
$element = $this
->getSession()
->getPage();
$radiobutton = $id ? $element
->findById($id) : $element
->find('named', array(
'radio',
$this
->getSession()
->getSelectorsHandler()
->xpathLiteral($field),
));
if ($radiobutton === NULL) {
throw new \Exception(sprintf('The radio button with "%s" was not found on the page %s', $id ? $id : $field, $this
->getSession()
->getCurrentUrl()));
}
if ($id) {
$value = $radiobutton
->getAttribute('value');
$labelonpage = $radiobutton
->getParent()
->getText();
if ($field != $labelonpage) {
throw new \Exception(sprintf("Button with id '%s' has label '%s' instead of '%s' on the page %s", $id, $labelonpage, $field, $this
->getSession()
->getCurrentUrl()));
}
}
}