I am using this ("browserstack/browserstack-local": "^1.1") package to run dusk tests on BrowserStack. Now the requirement is to run tests on multiple and different devices with different browsers. Currently, I am following this approach to run tests.
private function browserStackCaps($local_identifier)
{
return [
'project' => config('app.name'),
'browserstack.local' => 'true',
'browser' => env('BROWSER'),
'device' => env('DEVICE'),
'acceptSslCert' => true,
'resolution' => '1920x1080'
];
}
The drawback of this approach is I have to change the device name and browser name in the .env file every time I need to run tests on a different device/browser. Is there any way I can run tests on the provided array? The array that contains devices and browser information.
I know this is old, but I found this page while searching for a solution. I ended up building one myself that would probably meet your use-case. The biggest hurdle that I had was
$this->browse()
in a normal Dusk test was using a single instance ofLaravel\Dusk\Browser
and the new capabilities were not being pulled in. This implementation adds a function calledperformTest
to the DuskTestCase.php file. This function loops through a set of capabilities and instantiates a new instance ofLaravel\Dusk\Browser
for each test. This function works similarly to the existingbrowse
function in Laravel Dusk. You callperformTest
by passing it a callable that accepts a single parameter which is an instance ofLaravel\Dusk\Browser
Dusk Test Case
Example Test
config/browserstack.php