I want to use behat to example test and I used Mink and Selenium to test javascript. I have a a element in html file and when I click on the link then JQuery add to DOM new element. I want to test this case.
composer.json
{
"require": {
"behat/behat": "^3.1",
"bossa/phpspec2-expect": "^1.0",
"behat/mink-extension": "^2.2",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink": "^1.7"
}
}
behat.yml
default:
extensions:
Behat\MinkExtension:
goutte: ~
browser_name: firefox
selenium2:
wd_host: http://0.0.0.1:4444/wd/hub
example.feature
Feature: example
Scenario: Test javascript for
Given I am on "http://www.example.com/"
When I follow "clickButton" #a has id clickButton
Then I should see "Works!"
Behat throw error in Then I should see "Works!" step and it is fine, because this element not exists on body.
But when add @javascript annotation
@javascript
Feature: example
Scenario: Test javascript for
Given I am on "http://www.example.com/"
When I follow "clickButton"
Then I should see "Works!"
Behat throw exception:
When I follow "clickButton" # FeatureContext::clickLink() Link with id|title|alt|text "clickButton" not found. (Behat\Mink\Exception\ElementNotFoundException)
What's wrong? I have Selenium on server.