0

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?

Andrew
  • 2,148
  • 5
  • 23
  • 34

1 Answers1

1

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"
Nassim
  • 240
  • 1
  • 4
  • thanks a lot! It worked! I had just to adjust the step as follows: **Then I wait for 5 seconds**. – Andrew Sep 25 '13 at 11:43