Laravel Dusk provides simple end-to-end testing and browser automation.

Overview

Logo Laravel Dusk

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Dusk provides an expressive, easy-to-use browser automation and testing API. By default, Dusk does not require you to install JDK or Selenium on your machine. Instead, Dusk uses a standalone Chromedriver. However, you are free to utilize any other Selenium driver you wish.

Official Documentation

Documentation for Dusk can be found on the Laravel website.

Contributing

Thank you for considering contributing to Dusk! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

Laravel Dusk is open-sourced software licensed under the MIT license.

Comments
  • Update Chrome driver to support browser v74

    Update Chrome driver to support browser v74

    • Dusk Version: 5.0.3
    • Laravel Version: 5.8.14
    • PHP Version: 7.2.17
    • Database Driver & Version: mySQL 5.7.25

    Description:

    Chrome 74 is now available. The current driver has not been updated for 4 months and supports Chrome 70-73 only.

    (Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 4.15.0-47-generic x86_64) Facebook\WebDriver\Exception\SessionNotCreatedException: session not created: Chrome version must be between 70 and 73

    However...chromedriver 74.X does not explicitly support older versions: https://chromedriver.storage.googleapis.com/74.0.3729.6/notes.txt

    Compared to 2.45.X which clearly supports a range of versions 70-73 (and 2.46) but not 74: https://chromedriver.storage.googleapis.com/2.45/notes.txt https://chromedriver.storage.googleapis.com/2.46/notes.txt

    Does this mean we have to wait for a version that has a more encompassing support so we don't lose backwards compatibility? So we're either pinning Chrome to 73 or using a standalone driver rather than the packaged driver?

    Cheers.

    enhancement 
    opened by markdwhite 100
  • Can't run dusk tests on ubuntu 16.04

    Can't run dusk tests on ubuntu 16.04

    I am trying laravel dusk on a fresh installation laravel 5.4.x-dev This is what I get when I run php artisan dusk

    PHPUnit 5.7.5 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 7.0.13-0ubuntu0.16.04.1 with Xdebug 2.4.0
    Configuration: /var/www/html/dusk/phpunit.dusk.xml
    
    E                                                                   1 / 1 (100%)
    
    Time: 2.5 minutes, Memory: 10.00MB
    
    There was 1 error:
    
    1) Tests\Browser\ExampleTest::testBasicExample
    Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}
    
    Operation timed out after 30000 milliseconds with 0 bytes received
    
    /var/www/html/dusk/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:287
    /var/www/html/dusk/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:121
    /var/www/html/dusk/tests/DuskTestCase.php:32
    /var/www/html/dusk/vendor/laravel/dusk/src/TestCase.php:176
    /var/www/html/dusk/vendor/laravel/framework/src/Illuminate/Support/helpers.php:639
    /var/www/html/dusk/vendor/laravel/dusk/src/TestCase.php:177
    /var/www/html/dusk/vendor/laravel/dusk/src/TestCase.php:107
    /var/www/html/dusk/vendor/laravel/dusk/src/TestCase.php:81
    /var/www/html/dusk/tests/Browser/ExampleTest.php:21
    
    ERRORS!
    Tests: 1, Assertions: 0, Errors: 1.
    
    
    opened by babanesma 76
  • Problem running dusk on Homestead

    Problem running dusk on Homestead

    Hello,

    So I just installed a new Laravel 5.4 project and thought I'd give Dusk a try..

    Followed the installation steps in the documentation:

    1. Ran composer require laravel/dusk
    2. Updated AppServiceProvider.php
    3. Ran php artisan dusk:install

    But when I run php artisan dusk I get the following output:

    dir=$(d=${0%[/\\]*}; cd "$d"; cd "../phpunit/phpunit" && pwd)
    
    # See if we are running in Cygwin by checking for cygpath program
    if command -v 'cygpath' >/dev/null 2>&1; then
            # Cygwin paths start with /cygdrive/ which will break windows PHP,
            # so we need to translate the dir path to windows format. However
            # we could be using cygwin PHP which does not require this, so we
            # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
            if [[ $(which php) == /cygdrive/* ]]; then
                    dir=$(cygpath -m "$dir");
            fi
    fi
    
    dir=$(echo $dir | sed 's/ /\ /g')
    "${dir}/phpunit" "[email protected]"
    

    It seems to be outputting the script instead of executing it.

    I'm running latest Homestead on Windows 10 with PHP 7.1.0-2+deb.sury.org~xenial+1 (cli) ( NTS )

    PS. PHPUnit works as expected.

    opened by SaeedPrez 41
  • Curl error thrown for http POST

    Curl error thrown for http POST

    I am dynamicaly creating a browser for each exising user with bellow code snippet.

    
            $users = User::all();
    
            foreach($users as $user){
    
                $this->browse(
                    function ( Browser $one ) use ($user)
                    {
                        $search = array( 'stock', 'dollar', 'gold', 'market' );
                        $searchString = $search[ rand(0, sizeof($search) - 1 ) ];
    
                        $one->loginAs($user)
                            ->visit('/home')
                            ->waitForText('Bloomberg News')
                            ->type('search', $searchString );
                    }
                    );
    

    The test is throwing the bellow error.

    php artisan dusk
    PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
    
    E                                                                   1 / 1 (100%)
    
    Time: 1.11 minutes, Memory: 14.00MB
    
    There was 1 error:
    
    1) Tests\Browser\ExampleTest::testBasicExample
    Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session/d0eec334e467fffaf17d330d553bdbcc/url with params: {"url":"http:\/\/sandbox.com\/home"}
    
    Operation timed out after 30001 milliseconds with 0 bytes received
    
    /home/210390.cloudwaysapps.com/arfyvgtjzf/public_html/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:29
    2
    /home/210390.cloudwaysapps.com/arfyvgtjzf/public_html/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:547
    /home/210390.cloudwaysapps.com/arfyvgtjzf/public_html/vendor/facebook/webdriver/lib/Remote/RemoteExecuteMethod.php:40
    /home/210390.cloudwaysapps.com/arfyvgtjzf/public_html/vendor/facebook/webdriver/lib/WebDriverNavigation.php:85
    /home/210390.cloudwaysapps.com/arfyvgtjzf/public_html/vendor/laravel/dusk/src/Browser.php:137
    /home/210390.cloudwaysapps.com/arfyvgtjzf/public_html/tests/Browser/ExampleTest.php:30
    /home/210390.cloudwaysapps.com/arfyvgtjzf/public_html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:67
    /home/210390.cloudwaysapps.com/arfyvgtjzf/public_html/tests/Browser/ExampleTest.php:33
    
    
    needs more info 
    opened by ronlinet 39
  • ReflectionException: Class config does not exist

    ReflectionException: Class config does not exist

    Hi guys, recently upgraded a 5.3 project to 5.4 and all seemed good.

    Today I started to implement Dusk however had hit an issue when running the example test

    ☁  footy-finance [5.4] ⚡ php artisan dusk
    PHPUnit 6.0.0 by Sebastian Bergmann and contributors.
    
    E                                                                   1 / 1 (100%)
    
    Time: 162 ms, Memory: 6.00MB
    
    There was 1 error:
    
    1) Tests\Browser\ExampleTest::testBasicExample
    ReflectionException: Class config does not exist
    
    /Users/owen/Sites/footy-finance/vendor/laravel/framework/src/Illuminate/Container/Container.php:681
    /Users/owen/Sites/footy-finance/vendor/laravel/framework/src/Illuminate/Container/Container.php:565
    /Users/owen/Sites/footy-finance/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:105
    /Users/owen/Sites/footy-finance/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:263
    /Users/owen/Sites/footy-finance/vendor/laravel/dusk/src/TestCase.php:203
    /Users/owen/Sites/footy-finance/vendor/laravel/dusk/src/TestCase.php:40
    

    I've had a look at line 40 of TestCase.php and its

    public function baseUrl()
    {
        return config('app.url');
    }
    

    So it does look like something to do with the global config helper anybody have any ideas?

    I'm running

    • PHP 7.0.14
    • Laravel/Framework 5.4.8
    • Laravel/Dusk 1.0.5
    • PHPUnit 6.0

    The full composer.lock can be seen https://gist.github.com/OwenMelbz/c05172b33f6eb4483e37a56469b53722

    Fingers crossed you guys have some ideas!

    Cheers :)

    opened by OwenMelbz 34
  • Element is not clickable at (x, y)

    Element is not clickable at (x, y)

    I have a form which spans beyond the viewport and as a result the following test seems not able to find the button and reports the error;

    Facebook\WebDriver\Exception\UnknownServerException: unknown error: Element is not clickable at point (605, 869)
      (Session info: chrome=56.0.2924.87)
      (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Mac OS X 10.12.3 x86_64)
    

    Test below;

    $this->browse(function ($admin) {
                $admin->loginAs(User::find(1))
                    ->visit('/admin')
                    ->assertSee('Dashboard')
                    ->clickLink('Quick Links')
                    ->clickLink('Competitions')
                    ->assertSee('Competitions')
                    ->waitFor('.dropdown-toogle')
                    ->click('.dropdown-toogle')
                    ->assertSee('Copy')
                    ->clickLink('Copy')
                    ->type('name', 'Copy Competition 1')
                    ->check('active')
                    ->press('Save')
                    ->assertSee('Copy Competition 1');
            });
    

    I am really not sure why it can't see the button other than not showing within the viewport and will require a normal user to scroll down to get to the button. Not sure how to proceed beyond this point.

    Thanks!

    opened by stevepop 32
  • $browser->dump() always returns empty or blank html content

    $browser->dump() always returns empty or blank html content

    I have the same problem as this person: https://stackoverflow.com/questions/46868606/get-laravel-dusk-to-run-properly-on-ubuntu-16-wt-laravel-5-5

            $this->browse(function (Browser $browser) {
                $browser->visit('/')
                    ->dump()
                ;
            });
    

    this returns "<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>"

    That HTML is not generated by any of my blade files and it is affecting all my URLs.

    None of my assertions will work because dusk is getting that instead of my app.

    opened by carcinocron 27
  • Allow for Mocking Mail and Queue

    Allow for Mocking Mail and Queue

    There is some confusion around regarding mocks together with Laravel Dusk. It is not possible to mock Facades the normal way, because HTTP requests are sent to an actual webserver (or artisan serve command) that runs in a different process instead of emulating the request in the test process.

    But there is still a way how this could be done:

    • Implement new drivers that can be set as MAIL_DRIVER and QUEUE_DRIVER
    • In the .env.dusk file, these mock drivers will be set such that the Laravel instance in our webserver knows it should use them.
    • When the driver is instructed to send a mail or to queue a task, then it stores that information into a file instead of actually sending the mail
    • Inside the test case, we can use a mock interface like before, but it takes the information from the stored file instead of its internal state
    • After each test we should erase the file to start with a fresh setting in the next test case

    This works as long as the test case runs on a machine that has access to the same file system as the webserver. You could even run your application on a webserver in your staging environment, mount a folder from there with sshfs onto your local development machine and then start Dusk with APP_URL pointing to your staging environment.

    opened by SebastianS90 27
  • Implement a method

    Implement a method "isTtySupported" for setTty method.

    I tried dusk with PhantomJS on Wercker. and I have same issue this. https://laracasts.com/discuss/channels/testing/tty-mode-requires-devtty-to-be-writable

    Like that comment "run as script" can be executed. but Wercker continued build when dusk fails, probably exit code does not return. This problem will be occored on CircleCI, GitLab CI, cron and more.

    I fixed that, change to the same logic Symfony\Component\Process\Process#setTty() https://github.com/symfony/process/blob/master/Process.php#L1036

    and this is execution result.

    $ cat /tmp/test.php 
    <?php
    
    var_dump(PHP_OS !== 'WINNT');
    
    var_dump(PHP_OS !== 'WINNT' && (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes));
    

    iTerm2

    $ php /tmp/test.php 
    bool(true)
    bool(true)
    

    jenkins on MacOSX

    + php /tmp/test.php
    bool(true)
    bool(false) // no supported tty even if OS is not Windows.
    
    opened by mamor 27
  • Tests fail with the latest version of ChromeDriver

    Tests fail with the latest version of ChromeDriver

    • Dusk Version: v5.1.0
    • Laravel Version: v5.8.21
    • PHP Version: 7.3.5
    • Database Driver & Version: N/A

    Description:

    Tests are failing with the latest version of ChromeDriver 75.0.3770.8.

    Steps To Reproduce:

    • In a fresh installation of Laravel, add a link in the welcome.blade.php template:
      <a href="/click" class="link">Link</a>
      
    • Define a route for the /click path:
      Route::get('/click', function () {
          return 'clicked';
      });
      
    • Run this test:
      public function testBasicExample()
      {
          $this->browse(function (Browser $browser) {
              $browser->visit('/')
                      ->assertSee('Laravel')
                      ->click('.link')
                      ->assertPathIs('/click');
          });
      }
      

    The test is failing with version 75.0.3770.8 of ChromeDriver and is passing after php artisan dusk:chrome-driver 74.

    Chrome version: 75.0.3770.80 OS: Mac

    bug 
    opened by pdavide 26
  • type method not working as expected when called on single instance twice

    type method not working as expected when called on single instance twice

    I updated dusk to 4.0.4 and i found that dusk is not clearing input even if i use clear or call type method again on a single instance it just append to previous typed text

    bug 
    opened by AhmadWaleed 25
Releases(v7.0.2)
Owner
The Laravel Framework
The Laravel Framework
Inertia.js Events for Laravel Dusk

Inertia.js Events for Laravel Dusk Requirements PHP 7.4+ Vue Laravel 8.0 and higher Support We proudly support the community by developing Laravel pac

Protone Media 23 Sep 14, 2022
Persistent Fakes for Laravel Dusk

Laravel Dusk Fakes Support this package! ❤️ We proudly support the community by developing Laravel packages and giving them away for free. If this pac

Protone Media 3 Sep 5, 2022
Postier is a Laravel API automation platform to transfer data and to sync apps.

Postier is a Laravel API automation platform to transfer data and to sync apps. You can build workflows with data and actions of multiple apps and apply logics to the data!

null 51 Aug 30, 2022
Data driven home automation.

DataWhare Whare (Māori noun) house, building, residence, dwelling, shed, hut, habitation. Data driven home automation. Collects data from various sens

Mark Zeman 8 Sep 5, 2022
Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css. Requires Livewire and AlpineJS.

Laravel Livewire Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size W

Tina Hammar 14 Jun 1, 2022
Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css

Laravel Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size WITHOUT cs

Tina Hammar 6 Feb 10, 2022
Laravel Abdal Detector - Find info about IP , OS and web browser from your client

Laravel Abdal Detector - Find info about IP , OS and web browser from your client

 Abdal Security Group 1 Mar 24, 2022
Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Jameson Lopp 24 Jul 14, 2022
In-browser console for Laravel PHP framework.

Laravel 4 Console In-browser console for Laravel 4 PHP framework. This bundle executes your code within [email protected] context, and dis

null 173 May 3, 2022
View your Laravel routes on the browser.

View your Laravel routes on the browser. This package adds a route to your Laravel application. Once you've installed this package, enter /route-list

Patompong Savaengsuk 21 Apr 16, 2022
Intranet Home Page is a highly-configurable self-hosted browser homepage with integrations for public and local data feeds.

Intranet-Home-Page Created in response to personal "dashboards" that are little more than pages with a list of frequently accessed links, Intranet Hom

null 56 Aug 27, 2022
A helper package to flash a bootstrap alert to the browser via a Facade or a helper function.

Alert Box (Laravel) A helper package to flash a bootstrap alert to the browser via a Facade or a helper function. <div class="alert alert-info fade in

Ben-Piet O'Callaghan 18 Jan 25, 2022
File & Folders & Media Browser With Code Editor

Filament Browser File & Folders & Media Browser With Code Editor Features File Browser Code Editor with highlights Media Viewer .Env Editor Screenshot

Fady Mondy 16 Sep 21, 2022
Github repository dedicated for my YT tutorial which shows how to use testing in Laravel

Testing in Laravel The following documentation is based on my Laravel Testing for Beginners tutorial we’re going to cover the basics of unit tests, fe

Code With Dary 16 Sep 9, 2022
Trait for Laravel testing to count/assert about database queries

counts_database_queries Trait for Laravel testing to count/assert about database queries Installing composer require ohffs/counts-database-queries-tra

null 1 Feb 23, 2022
Providing some testing functionality for Laravel

Laravel TestBench Laravel TestBench was created by, and is maintained by Graham Campbell, and provides some testing functionality for Laravel. It util

Graham Campbell 49 Feb 6, 2022
Eloquent scope assertion for testing Laravel applications.

Eloquent Scope Assertion This package allows you to assert that the scope of a model is called in your tests. Installation You can install the package

Turan Karatuğ 14 Aug 12, 2022
Video Chat application built using Metered Video SDK, with PHP Laravel Backend and JavaScript Front-End

Group Video Chat App with PHP Laravel and JavaScript Powered by Metered Video SDK Overview This application is a highly scalable group video calling a

null 2 Aug 18, 2022
Otpify is a Laravel package that provides a simple and elegant way to generate and validate one time passwords.

Laravel Otpify ?? Introduction Otpify is a Laravel package that provides a simple and elegant way to generate and validate one time passwords. Install

Prasanth Jayakumar 2 Sep 2, 2022