Skip to content
Nikhil edited this page Feb 4, 2019 · 2 revisions

LambdaTest Logo

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 file
        cp .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 configuration
    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", false)
        );

Routing traffic through your local machine

  • Set tunnel value to true in test capabilities (found in driver method of tests/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.