I am writing Behat tests and I need to change the value of a hidden input field
<input type="hidden" id="input_id" ..... />
I need to change the value of this input field, but I keep getting
Form field with id|name|label|value "input_id" not found
I have been using the step
$steps->And('I fill in "1" for "input_id"', $world);
Is there something special which needs to be done to modify hidden input fields?
Despite the fact that user can't fill hidden fields, there are some situations when this is desirable to be able to fill hidden field for testing (as usually rules have exceptions). You can use next step in your feature context class to fill hidden field by name:
/**
* @Given /^I fill hidden field "([^"]*)" with "([^"]*)"$/
*/
public function iFillHiddenFieldWith($field, $value)
{
$this->getSession()->getPage()->find('css',
'input[name="'.$field.'"]')->setValue($value);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With