This is a test repository for learning and test Laravel Dusk with Selenium.
- Install composer library on Laravel project:
composer require --dev laravel/dusk
- Do the Laravel Dusk install command.
php artisan dusk:install
- Add on .env file the username and API Key of LambdaTest, both can be found in your acoount profile.
.env
LT_USERNAME="your username"
LT_ACCESS_KEY="your access key"
- in the folder tests/DuskTestCase.php comment the content of prepare() method and add in driver method before return:
$options = (new ChromeOptions)->addArguments([
'--headless',
'--disable-gpu',
'--no-sandbox',
'--ignore-certificate-errors',
]);
$username = env('LT_USERNAME');
$access_key = env('LT_ACCESS_KEY');
$url = "https://".$username.":".$access_key."@hub.lambdatest.com/wd/hub";
return RemoteWebDriver::create($url, {DesiredCapabilities});
- Replace {DesiredCapabilities} by the contents generated by this link. Important that 'tunnel' is set as true to everything work.
- Download the lambdatest zip achive and extract the LT binary.
- Then in terminal in same folder that are the LT binary copy and paste the command in "configure tunel" of lambdatest dashboard (remember to select 'home' checkbox) and replace '/home/selenium' for the path to public folder of project.
- Generate the test:
php artisan dusk:make {class}Test
-
Write the tests.
-
Test:
php artisan dusk