title: Selenium 'dies' when visiting some websites using Behat / Mink
body: <p>I'm trying to create a a custom scenario in Behat / Mink using the javascript capabilities of Selenium but I've hit a peculiar snag.  I've stripped everything back to the bare bones to lay the problem out as simply as possible but in summary when calling visit() in Selenium, some websites run fine but other (including my own) return the error "Error communicating with the remote browser. It may have died." in behat which terminates the scenario.</p>
  
  <p>In detail:</p>
  
  <p>My behat.yml file looks like this:</p>
  
  <pre><code>default:
    paths:
     features: features
     bootstrap: %behat.paths.features%/bootstrap
  extensions:
    Behat\MinkExtension\Extension:
      base_url: http://www.foo.bar
      goutte: ~
      selenium2:
        browser: 'firefox'
  </code></pre>
  
  <p>In my FeatureContext.php file I have the following custom function:</p>
  
  <pre><code>public function iAmLoggedIn()
  {
      $session = $this-&gt;getSession();
      $session-&gt;visit("http://www.foo.bar");
  {
  </code></pre>
  
  <p>Now when I run the scenario in Behat that uses the custom function I get the following error:</p>
  
  <pre><code>PHP Fatal error:  Uncaught exception 'WebDriver\Exception\UnknownError' with message 'Error communicating with the remote browser. It may have died.
  Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
  Driver info: driver.version: EventFiringWebDriver' in /var/www/behat/vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:157
  Stack trace:
  #0 /var/www/behat/vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(140):     WebDriver\Exception::factory(13, 'Error communica...')
  #1 /var/www/behat/vendor/instaclick/php-webdriver/lib/WebDriver/Session.php(151): WebDriver\AbstractWebDriver-&gt;curl('DELETE', '')
  #2 /var/www/behat/vendor/behat/mink-selenium2-driver/src/Behat/Mink/Driver/Selenium2Driver.php(292): WebDriver\Session-&gt;close()
  #3 /var/www/behat/vendor/behat/mink/src/Behat/Mink/Session.php(70): Behat\Mink\Driver\Selenium2Dri in /var/www/behat/vendor/behat/mink-selenium2-driver/src/Behat/Mink/Driver/Selenium2Driver.php on line 294
  </code></pre>
  
  <p>But here's the oddity: thinking that this may have been an issue with my website (www.foo.bar) I tried a different website by editing the line on the function:</p>
  
  <pre><code>$session-&gt;visit("http://www.bbc.co.uk");
  </code></pre>
  
  <p>This time no error and the scenario continues as normal.  Good old BBC.  To make sure I also tried Goole:</p>
  
  <pre><code>$session-&gt;visit("http://www.google.com");
  </code></pre>
  
  <p>But this time I get exactly the same error: 'Error communicating with the remote browser. It may have died.'.  Weird.  So I try a number of other websites, some work fine, others return this error.  There doesn't seem to be any obvious similarity between those sites that kill Selenium, and those that don't.  So what is Selenium saying?</p>
  
  <p>Output from a site that returns the 'It may have died' error:</p>
  
  <pre><code>11:41:41.428 INFO - Executing: [new session: Capabilities [{platform=ANY, browserVersion=8, browserName=firefox, deviceType=tablet, selenium-version=2.31.0, name=Behat test, browser=firefox, deviceOrientation=portrait, max-duration=300, version=8}]])
  11:41:41.430 INFO - Creating a new session for Capabilities [{platform=ANY, browserVersion=8, browserName=firefox, deviceType=tablet, selenium-version=2.31.0, name=Behat test, browser=firefox, deviceOrientation=portrait, max-duration=300, version=8}]
  11:41:44.024 INFO - Done: [new session: Capabilities [{platform=ANY, browserVersion=8, browserName=firefox, deviceType=tablet, selenium-version=2.31.0, name=Behat test, browser=firefox, deviceOrientation=portrait, max-duration=300, version=8}]]
  11:41:44.031 INFO - Executing: [get: http://www.foo.bar//])
  11:41:50.478 INFO - Executing: [delete all cookies])
  11:41:50.494 INFO - Executing: [delete session: cee7cfa5-bc53-4804-a9a4-f6b52b0f48df])
  </code></pre>
  
  <p>Output from a site that does not return the error:</p>
  
  <pre><code>11:19:19.930 INFO - Executing: [new session: Capabilities [{platform=ANY, browserVersion=8, browserName=firefox, deviceType=tablet, selenium-version=2.31.0, name=Behat test, browser=firefox, deviceOrientation=portrait, max-duration=300, version=8}]])
  11:19:19.936 INFO - Creating a new session for Capabilities [{platform=ANY, browserVersion=8, browserName=firefox, deviceType=tablet, selenium-version=2.31.0, name=Behat test, browser=firefox, deviceOrientation=portrait, max-duration=300, version=8}]
  11:19:24.607 INFO - Done: [new session: Capabilities [{platform=ANY, browserVersion=8, browserName=firefox, deviceType=tablet, selenium-version=2.31.0, name=Behat test, browser=firefox, deviceOrientation=portrait, max-duration=300, version=8}]]
  11:19:24.614 INFO - Executing: [get: http://www.bbc.co.uk/])
  11:19:43.454 INFO - Done: [get: http://www.bbc.co.uk/]
  11:19:43.463 INFO - Executing: [delete all cookies])
  11:19:46.263 INFO - Done: [delete all cookies]
  11:19:49.935 INFO - Executing: [delete all cookies])
  11:19:49.955 INFO - Done: [delete all cookies]
  11:19:50.389 INFO - Executing: [delete session: a092aa77-ad26-4f6f-8fc1-f290b688d7fa])
  11:19:50.488 INFO - Done: [delete session: a092aa77-ad26-4f6f-8fc1-f290b688d7fa]
  </code></pre>
  
  <p>No clue there apart from the fact that Selenium completes the 'get' of bbc.co.uk but not of foo.bar.  So what about the access logs for foo.bar?  They seem normal:</p>
  
  <pre><code>10.179.?.? - - [06/Jan/2015:10:52:57 +0000] "GET / HTTP/1.1" 401 486 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
  10.179.?.? - tester [06/Jan/2015:10:52:57 +0000] "GET / HTTP/1.1" 200 33141 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
  10.179.?.? - tester [06/Jan/2015:10:53:00 +0000] "GET /css/page_specific_css/index.css HTTP/1.1" 200 10234 "http://www.foo.bar/" "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
  10.179..?.? - tester [06/Jan/2015:10:53:00 +0000] "GET /library/jquery-tools.min.js HTTP/1.1" 200 5920 "http://www.foo.bar/" "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
  </code></pre>
  
  <p>10.179.?.? being the IP of the CI server so it's communicating with the server fine and retrieving all the assets.  So I'm not sure if this is a Selenium issue or a Behat / Mink issue but I'm at a loss.  There doesn't seem to be any logical reason why some sites work and other's don't.  Any help would be greatly appreciated.</p>