Yonibrese's avatar

Running a single dusk test with multiple Browsers working one at a time

Hello,

For A project that I am working on I need to build a specific Dusk test. It needs to preform the following way. First It needs to open the browser and do some assertions, Then it needs to close the browser. In the same test/function It needs to open anther browser after the first is closed then run some other assertions.

The following is a straw-mans version of the test that I want to do:

class TrailTest extends DuskTestCase
{
    /**
     * A Dusk test example.
     * here is the command line code to run
     * php artisan dusk --filter testTrail
     * @return void
     */

    public function testTrail(){
      $this->testTwo("https://www.google.com");
      // I need to run the same basic function in a new window 
      $this->testTwo("https://www.bing.com");   
    }

    public function testTwo($website){
      $this->browse(function(Browser $browser) use ($website){  
        $browser->visit($website);
        $browser->pause(5000);
        // Do something here ... 
        $browser->quit();
      });
    }
}

When I run this code, the first run of the function (google.com in this case) works perfectly. but the second function (bing.com) does not work. The browser does not open and I get the following error:

1) Tests\Browser\TrailTest::testTrail
Facebook\WebDriver\Exception\UnknownErrorException: Unexpected server response to findElement command

Is there a way to build this dusk test with the parameters that I described?

0 likes
0 replies

Please or to participate in this conversation.