Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

You can use example below to click radio option with given label content.


HTML content


Step definition Then I check the "Multiple sizes" radio button.



FeatureContext.php


class FeatureContext extends MinkContext
{
/**
* @Then /^I check the "([^"]*)" radio button$/
*
* @param $radioLabel
* @throws \Behat\Behat\Exception\BehaviorException
*/
public function iSelectTheRadioButton($radioLabel)
{
$radioButton = $this->getSession()->getPage()->findField($radioLabel);

if (null === $radioButton) {
throw new BehaviorException("Element not found");
}

$this->getSession()->getDriver()->click($radioButton->getXPath());
}
}