Symfony2 Behat - check checkbox if not checked yet (with onclick event)
I check "checkbox_id"' doesn't work for me
Behat includes method for checking checkboxes, but it have one disadvantage - when it is run on Selenium server it only tacks checkbox value but don't fire onclick event. I write some small snippet to handle this flaw.
Code snippet
/**
* @When /^I check "([^"]*)" if not checked yet$/
*/
public function iCheckIfNotCheckedYet($id)
{
$Page = $this->getSession()->getPage();
$isChecked = $Page->find('css', 'input[type="checkbox"]:checked#' . $id);
if (!$isChecked) {
$Page->find('css', '#' . $id)->click();
}
}
It checks if checkbox is checked, if not it fire click action on it.
Written by Jacek Wysocki
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Event
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#