I'm using laravel 5.6
and Dusk
for running some tests.
I'm always taking my screenshot like this
...
use Facebook\WebDriver\WebDriverDimension;
...
class LoginTest extends DuskTestCase
{
public function testLogin()
{
$user = User::first();
$this->browse(function ($browser) use ( $user ) {
$test = $browser->visit( new Login)
->resize(1920,1080)
...
->driver->takeScreenshot(base_path('tests/Browser/screenshots/testLogin.png'));
});
}
}
But as my tests will be more and more used, I don't want to continue to write everytime ->resize(X,Y)
and base_path('bla/blab/bla')
.
I wanted to define the size and path for every tests that will be written.
I guess I should define some function in tests/DesukTestCase.php
but I'm not even aware of how I can retrieve the driver and so on.
Have you got some guidance or documentation about this? Because I can't find anything...
In my
DuskTestCase
file I have the below in mydriver()
function.You should just be able to configure it with the right dimensions you need.
You only need to add
'--window-size=1920,1080'
in$options
. This will apply a 1920x1080 screen resolution to all your Dusk tests. Feel free to adjust to whatever window size you want.So your DuskTestCase.php file should look like this: