Search code examples
phptestingautomationbehatmink

How to access spaced string of value attribute in Behat?


I am not able to click on submit button. I have html as shown below.

`<input id="edit-submit" class="form-submit" type="submit" value="Achteraf betalen" name="submit" onclick="return validate_step3();">` <br>

I am using the iPress function as shown below in features.php file. I tried with iClick(), iClickElementWithId() But not able click at all.

/**
 * @Given /^I Press "([^"]*)"$/
 */
public function iPress($value)
{
    $val="$value";
    $page = $this->getSession()->getPage();
    $element = $page->find('css',"input[value=$val]");
    $element->doubleClick();
}

I am getting the below error message while executing.

And I Press "Achteraf betalen" Expected "]", but found.

So, please give some suggestions.. Thanks in advance..


Solution

  • The problem is in your $page->find() call. Enclose the value in quotes:

    $element = $page->find('css',"input[value='$val']");