Behat and PhantomJs
Using PhantomJS both with Selenium and in replace of Selenium
With Selenium
Here is my example behat profile for this one
phantom_via_selenium:
paths:
features: app/tests/acceptance/features/ui
bootstrap: app/tests/acceptance/contexts
context:
parameters:
base_url: https://behat.dev:443
asset_path: '/tmp/'
extensions:
Behat\MinkExtension\Extension:
default_session: selenium2
goutte:
guzzle_parameters:
curl.options:
CURLOPT_SSL_VERIFYPEER: false
CURLOPT_CERTINFO: false
CURLOPT_TIMEOUT: 120
ssl.certificate_authority: false
selenium2:
wd_host: "http://selenium-server.dev:4444/wd/hub"
capabilities:
browser: phantomjs
base_url: 'https://behat.dev:443'
browser_name: 'phantomjs'
And as usual you start up selenium.
In both cases the test is this one
@javascript @thisone
Feature: Testing
Scenario: Testing Wiki
Given I am on "http://en.wikipedia.org/wiki/Main_Page"
Then I should see "Wiki"
And I take a screenshot
This allows me to take screenshots as well screenshot which is super handy.
Also note http://selenium-server.dev:4444/wd/hub
works because in my /etc/hosts file I set 127.0.0.1 to be that domain. You could easily do http://127.0.0.1:4444/wd/hub
Without Selenium
This one will now run via phantom as the “selenium” server
phantom_ui:
paths:
features: app/tests/acceptance/features/ui
bootstrap: app/tests/acceptance/contexts
context:
parameters:
base_url: https://behat.dev:443
asset_path: '/tmp/'
extensions:
Behat\MinkExtension\Extension:
default_session: selenium2
goutte:
guzzle_parameters:
curl.options:
CURLOPT_SSL_VERIFYPEER: false
CURLOPT_CERTINFO: false
CURLOPT_TIMEOUT: 120
ssl.certificate_authority: false
selenium2:
wd_host: "http://localhost:8643/wd/hub"
capabilities:
browser: phantomjs
base_url: 'https://behat.dev:443'
browser_name: 'phantomjs'
This is really thanks to http://shashikantjagtap.net
Running phantom in the background as phantomjs --webdriver=8643
Coming up
Self Signed SSL
Render Tree dumps of the site for later parsing
comments powered by Disqus