Question

I'm writing acceptance tests for my php application using Behat/Mink and found out a strange thing: Behat can not find an input field when javascript is on, while it finds the same field when javascript is off.

To be precise: the following scenario

Scenario: adding article keywords, no javascript used
 Given I am on "articles/create"
 When I fill in "Articles[title]" with "About all properties"
...

passes perfectly. But as soon as I add tag javascript to the above scenario

@javascript    
Scenario: adding article keywords
 Given I am on "articles/create"
 When I fill in "Articles[title]" with "About all properties"

it starts to fail:

When I fill in "Articles[title]" with "About all properties"
# FeatureContext::fillField()
Form field with id|name|label|value "Articles[title]" not found.

What might be the reason?

Was it helpful?

Solution

The @javascript will run your feature using the Selenium driver, Selenium may take some time to load a page, you could try adding a step 'I wait ...' right after the 'I am on ...'. Hopefully, it's just the DOM taking time to load.

@javascript    
Scenario: adding article keywords
 Given I am on "articles/create"
 Then I wait 1000
 When I fill in "Articles[title]" with "About all properties"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top