Behat Mink: 08 - phantomjs

  • phantomjs is a headless browser with full javascript support
  • driven via CLI
  • simply place the binary in the system path ( or add it )
  • accessible via DOS Shell, PowerShell, CMDER, or Linux Shell utils
  •  

 


Important Links

 


StackOverflow:

https://stackoverflow.com/questions/28449142/phantomjs-behat-form-field-not-found-when-executing-in-my-server

When I launch my tests, I've got this problem :

 @javascript
 Scenario: Searching for a page that does NOT exist                             
Given I am on "http://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal" 
When I fill in "searchInput" with "Glory Driven Development"                 
  Form field with id|name|label|value "searchInput" not found.

My settings in behat.yml is as following

phantomjs:
context:
      class:  'FeatureContext'
  extensions:
    Behat\MinkExtension\Extension:
      goutte: ~
      selenium2:
        wd_host: "http://localhost:8643/wd/hub"
        capabilities:
            proxy:
               proxyType: direct

My test is as following

@javascript 
Scenario: Searching for a page that does NOT exist
Given I am on "http://fr.wikipedia.org/wiki/WikipC3%A9dia:Accueil_principal"
When I fill in "searchInput" with "Glory Driven Development"
And I press "searchButton"
Then I should see "Search results"

I can't understand why it says : "Form field with id|name|label|value "searchInput" not found". I have launched phantomjs and even selenium.

Does someone has an idea ? Thank you


I was trying same scenario today.

Driver is complaining about not finding the element. So I debug a bit the test case and found that the page browsed by driver was different than the one expected.

When the driver does: $this->getSession()->getPage(). Be sure you are in the expected page and receiving expected html.