Skip to content

Behat phantomJs install

YaronMiro edited this page Nov 30, 2014 · 14 revisions

First install phantomJs.

Install phantomJs on local machine.

  • (linux)
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install libfontconfig1 libfontconfig1-dev
sudo apt-get install phantomjs
  • (mac - with brew)
brew update && brew install phantomjs

Use phantomJs.

  • Activate phantomJs from the terminal in a new tab (This should be kept running with the behat testing).
phantomjs --webdriver=8643
  • If the phantomJs won't run on linux, please apply the following commands:
export PHANTOM_JS="phantomjs-1.9.7-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo mv $PHANTOM_JS.tar.bz2 /usr/local/share/
sudo tar xvjf /usr/local/share/$PHANTOM_JS.tar.bz2
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/share/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin/phantomjs

Second, Install and run behat.

  • We need to activate Behat. cd to the behat directory.

  • Copy the behat.yml example file

cp behat.local.yml.example behat.local.yml
  • If you never activated behat before, you need download composer with the following commands:
curl http://getcomposer.org/installer | php
sudo apt-get install curl
  • Add the following dependencies to your composer.json
{
  "require": {
    "drupal/drupal-extension": "v0.1.5",
    "behat/behat": "2.5.*@stable",
    "behat/mink": "1.5.*@stable",
    "behat/mink-extension": "*",
    "behat/mink-browserkit-driver": "*",
    "behat/mink-selenium2-driver": "*"
  },
  "config": {
    "bin-dir": "bin/"
  }
}
  • Add phantomJs to your behat.yml
phantomjs:
  context:
      class:  'FeatureContext'
  extensions:
    Behat\MinkExtension\Extension:
      goutte: ~
      selenium2:
        wd_host: "http://localhost:8643/wd/hub"
  • Install the composer.phar
php composer.phar install
  • Run behat with phantomJS with this command:
bin/behat -p phantomjs

If you get this error: Drupal\Exception\BootstrapException]
Unable to determine Drupal core version. Supported versions are 6, 7, and 8.

Check the path of the drupal installation in your new behat.yml.local file.

  • (Using phantomJs)
The test must have n ```@javascript``` tag.
when a test is using ```phantomJs``` you can see it's output on the ```GhostDriver``` in the terminal window.
Clone this wiki locally