PHP Laravel Dusk todo
A Sample PHP-Laravel app to run selenium automation tests on LambdaTest grid.
Prerequisites
- Install php and composer on your system. Setup Instructions for the same can be found here
Installation
# setup project dependencies
composer install
composer dump-autoload
Configuration steps
- Create
.env
from example filecp .env.example .env
- Replace
LT_USERNAME
with your LambdaTest username. It can be obtained from LambdaTest dashbaord - Replace
LT_ACCESS_KEY
with your access key. It can be generated from LambdaTest dashbaord - Update platform configuration in driver method of
tests/DuskTestCase.php
, to specify the target where tests should run. (List of supported OS platfrom, Browser, resolutions can be found at LambdaTest capability generator) Sample configurationreturn RemoteWebDriver::create($url, DesiredCapabilities::chrome() ->setCapability("platform", "win10") ->setCapability("browserName", "chrome") ->setCapability("version", "71.0") ->setCapability("resolution", "1024x768") ->setCapability("build", "LaravelDusk Build") ->setCapability("name", "LaravelDusk Test") ->setCapability("network", true) ->setCapability("video", true) ->setCapability("visual", true) ->setCapability("console", true) ->setCapability("tunnel", false) );
Routing traffic through your local machine
-
Set tunnel value to
true
in test capabilities (found in driver method oftests/DuskTestCase.php
).e.g:
return RemoteWebDriver::create($url, DesiredCapabilities::chrome() ->setCapability("platform", "win10") ->setCapability("browserName", "chrome") ->setCapability("version", "71.0") ->setCapability("resolution", "1024x768") ->setCapability("build", "LaravelDusk Build") ->setCapability("name", "LaravelDusk Test") ->setCapability("network", true) ->setCapability("video", true) ->setCapability("visual", true) ->setCapability("console", true) ->setCapability("tunnel", true) );
OS specific instructions to download and setup tunnel binary can be found at the following links.
Run tests
php artisan dusk
Generate test cases
- Change directory to project root
cd /your/project
- Execute
php artisan dusk:make {test case name}
e.g:php artisan dusk:make TodoTest
Note
Our sample test case can be found in tests/Browser/TodoTest.php
file. It navigates to our sample to-do app.
About LambdaTest
LambdaTest is a cloud based selenium grid infrastructure that can help you run automated cross browser compatibility tests on 2000+ different browser and operating system environments. LambdaTest supports all programming languages and frameworks that are supported with Selenium, and have easy integrations with all popular CI/CD platforms. It's a perfect solution to bring your selenium automation testing to cloud based infrastructure that not only helps you increase your test coverage over multiple desktop and mobile browsers, but also allows you to cut down your test execution time by running tests on parallel.