Getting started testing Javascript interactions with Drupal 7, Behat 3, Selenium2
<p>I have been stuck on how to configure my Drupal 7 site to work with Behat to test Javascript interactions.  </p>

<p>This is the setup I am starting with.  If someone could help me modify my configuration to support testing Javascript I would greatly appreciate it.</p>

<p>Vagrant 1.8.1 running:
 - Ubuntu 14.04.2 LTS
 - PHP 5.6.22-1+donate.sury.org~trusty+1 (cli)
 - Drupal 7.41
 - Selenium: selenium-server-standalone-2.46.0.jar</p>

<p>I started Selenium using the following commands:</p>

<pre><code>java -jar /opt/selenium/selenium-server-standalone.jar -role hub -port 4444
java -jar /opt/selenium/selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register
</code></pre>

<p>It looks like Selenium is running: <code>lsof -i -n -P | grep 4444</code></p>

<pre><code>php     2428 vagrant    6u  IPv6  22327      0t0  TCP [::1]:46489-&gt;[::1]:4444 (CLOSE_WAIT)
</code></pre>

<p>composer.json</p>

<pre><code>{
    "require-dev": {
        "drush/drush": "7.1.0",
        "drupal/coder": "7.2.5",
        "phpunit/php-timer": "dev-master",
        "pear/Console_Color2": "0.1.2",

        "behat/behat": "3.1.0",
        "behat/mink": "1.7.1",
        "behat/mink-extension": "2.2",      
        "behat/mink-goutte-driver": "1.2.1",
        "behat/mink-selenium2-driver": "1.3.1",         
        "drupal/drupal-extension": "3.2.1"
    },
    "config": {
        "bin-dir": "bin/"
    } 
}
</code></pre>

<p>behat.yml</p>

<pre><code># behat.yml
default:
    autoload: [ %paths.base%/contexts ]
    extensions:
      Behat\MinkExtension:
        goutte: ~
        selenium2: ~
        base_url: http://test.dev
      Drupal\DrupalExtension:
        blackbox: ~
    suites:
        default:
            paths:    [ %paths.base%/features ]
            filters:
            contexts:
              - FeatureContext
              - Drupal\DrupalExtension\Context\DrupalContext
              - Drupal\DrupalExtension\Context\MinkContext
              - Drupal\DrupalExtension\Context\MessageContext
              - Drupal\DrupalExtension\Context\DrushContext
</code></pre>

<p>contexts/FeatureContext.php</p>

<pre><code>&lt;?php

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;

/**
 * Defines application features from the specific context.
 */
class FeatureContext implements Context, SnippetAcceptingContext
{
    /**
     * Initializes context.
     *
     * Every scenario gets its own context instance.
     * You can also pass arbitrary arguments to the
     * context constructor through behat.yml.
     */
    public function __construct()
    {
    }
}
</code></pre>

<p>features/test.feature</p>

<pre><code>Feature: Test DrupalContext
  In order to prove the Drupal context using the blackbox driver is working properly
  As a developer
  I need to use the step definitions of this context

  @javascript
  Scenario: Test the ability to find a heading in a region
    Given I am on the homepage
    When I click "some link"
    Then I should see the heading "Some heading"
</code></pre>

<p>When I run test.feature <code>behat features/test.feature</code> I get the following output.  <em>I do not know how to get the stack trace to output.  If you can tell me how I will add that information to my post.</em></p>

<pre><code>Feature: Test DrupalContext
  In order to prove the Drupal context using the blackbox driver is working properly
  As a developer
  I need to use the step definitions of this context

  @javascript
  Scenario: Test the ability to find a heading in a region      # features/test.feature:7
    Given I am on the homepage                                  # Drupal\DrupalExtension\Context\MinkContext::iAmOnHomepage()
      Could not open connection (Behat\Mink\Exception\DriverException)
    When I click "some link"                                    # Drupal\DrupalExtension\Context\MinkContext::assertClick()
    Then I should see the heading "Some heading"                # Drupal\DrupalExtension\Context\MinkContext::assertHeading()
</code></pre>