Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbaginski/7911061 to your computer and use it in GitHub Desktop.
Save jbaginski/7911061 to your computer and use it in GitHub Desktop.

Making behat use phantomjs for the tests

If you want to run it on phantomjs (a headless browser) you can add this profile to your behat.yml and you need phantomjs >= 1.8.0

phantomjs:
    extensions:
        Behat\MinkExtension\Extension:
            base_url: http://dev.local
            goutte: ~
            selenium2:
                wd_host: "http://localhost:8643/wd/hub" 

    formatter:
        name:               pretty,html
        parameters:
            output_path:    null,jm_behat_report.html

start up the phantomjs web driver using: $ phantomjs --webdriver=8643

then run using:

$ ./bin/behat -p phantomjs

Note: You don't need to have selenium running as it communicates directly with the webdriver server that phantomjs/ghostdriver starts

Note2: apparently there is also a way to have it run by registering with a selenium hub and requesting the browserName 'phantomjs' but I couldn't get it to work, see https://github.com/detro/ghostdriver#register-ghostdriver-with-a-selenium-grid-hub or the copied instructions below

========== copied from ghostdriver ============

  1. Launch the grid server, which listens on 4444 by default: java -jar /path/to/selenium-server-standalone-2.25.0.jar -role hub
  2. Register with the hub: phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444
  3. Now you can use your normal webdriver client with http://127.0.0.1:4444 and just request browserName: phantomjs

========== copied from ghostdriver ============

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment