Behat mink ChromeDriver multiple independent sessions are not stopping independently

361 Views Asked by At

I'm trying to have multiple sessions of Behat Mink ChromeDriver running in the same time independently.

First of all I start Chrome with the right debugging port:

$ google-chrome-stable --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222

Let's say I want two sessions that I start like this:

use Behat\Mink\Mink;
use Behat\Mink\Session;
use DMore\ChromeDriver\ChromeDriver;

// session 1
$driver1 = new ChromeDriver('http://localhost:9222', null, 'http://www.google.com');
$mink1 = new Mink(array('tab1' => new Session($driver1)));
$mink1->setDefaultSessionName('tab1');
$mink1->getSession()->visit("http://www.google.com");

// session 2
$driver2 = new ChromeDriver('http://localhost:9222', null, 'http://www.google.com');
$mink2 = new Mink(array('tab2' => new Session($driver2)));
$mink2->setDefaultSessionName('tab2');
$mink2->getSession()->visit("http://www.bing.com");

//changing the url of session 1
$mink1->getSession()->visit("http://www.yahoo.com");

Everything goes smoothly until here: Chrome is open and I have two tabs with the correct url displayed. I can change the url of each session independently, everything is all right. But when I stop one of the two sessions, the two sessions stop together:

$mink2->getSession()->stop();

The two tabs are closed and the session 1 ($mink1) is no longer accessible:

$mink1->getSession()->visit("http://www.bing.com");    
DMore/ChromeDriver/StreamReadException

Any idea why this is happening? In the documentation (http://mink.behat.org/en/latest/guides/managing-sessions.html) it says that each session must use a different driver instance. I believe it's what I'm doing, right?

0

There are 0 best solutions below