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 installation. However, you are free to utilize any other Selenium compatible driver you wish.
Questions tagged [laravel-dusk]
477 questions
6
votes
3 answers
Running Laravel Dusk on Headless (no GUI) machine
With the recent announcement of Laravel 5.4, I thought I'd give it a try. Like Ozymandias-X on Reddit, I also have been frustrated by it.
My Setup
Windows 10 as Host;
CentOS 7 as Guest (no GUI installation, no Vagrant)
Shared folder with Virtual…

Marco Aurélio Deleu
- 4,279
- 4
- 35
- 63
6
votes
4 answers
Migrate only once with Laravel dusk
According to the "Database Testing" documentation I can reset the database after each test (first option). Second option is to run test using Transactions. It seems a better approach to me, but if I want to run with transaction, the migration does…

rap-2-h
- 30,204
- 37
- 167
- 263
5
votes
0 answers
How to get session data in Laravel Dusk?
I was wondering why we cannot get the session data when testing with Laravel Dusk ?
In any controller in Laravel we can get session data with Session::get('data');
When we are running a Laravel Dusk test, we take a screenshot with the phpdebugbarr…

leoden
- 301
- 3
- 10
5
votes
1 answer
Is there an assertDatabaseHas wildcard 'like' compare clause similar to Eloquent's 'like', (i.e. '%' . . '%')
I am running laravel dusk tests.
I am trying to determine whether the database has a record which contains a string.
Eloquent has a wildcard where clause that performs this activity.
i.e. 'like', '%' . $stringToSearch . '%'
I am trying to find a…

Greenie
- 113
- 1
- 11
5
votes
4 answers
Laravel Dusk and memory usage - how to close the browser and custom process
I'm using Laravel Dusk in the controller for users to get screenshots of the any website using mine website.
My code:

Aleks Per
- 1,549
- 7
- 33
- 68
5
votes
3 answers
Laravel Dusk: How to get HTML from element?
I understand that you can get the text from an element, like this:
$text = $browser->text('.selector');
My question is: How can you get the raw HTML content? E.g. the following doesn't work
$text = $browser->html('.selector');
E.g. if the element…

user6122500
- 892
- 1
- 15
- 31
5
votes
1 answer
Simulate HTTP_REFERER in a Laravel Dusk test?
Is there a straightforward way to simulate HTTP_REFERER in a Dusk test? I'm using Laravel\Dusk\Browser and calling the visit() method on various pages. This is using the Selenium driver.
Something like setReferer below:
namespace…

artlung
- 33,305
- 16
- 69
- 121
5
votes
1 answer
Simulate key with Laravel Dusk (without input element)
I have a page which consists of some disabled inputs, spans and divs.
In the background I wait for pressed keys. Background of this is some memory game.
My problem is, that it turned out to be pretty hard to test.
I know two functions to simulate…

TimSch
- 1,189
- 1
- 12
- 27
5
votes
0 answers
Overwrite trait in Laravel to change behaviour of Dusk
I have a Laravel 5.4 project and are trying to use Dusk to run some test. I want to reset, migrate and seed before I run my test. I've got it setup to use SQLite and ideally want to run it in memory, but a physical file is also fine.
I was able to…

Matthieu
- 437
- 6
- 16
5
votes
1 answer
Assert that there are certain number of elements on the page
I was writing a test with Laravel Dusk to make sure there are, let's say, 10 articles on the index page.
Here is some HTML code:
A list of articles
-
@foreach($articles as $article)
- {{…

Carter
- 1,230
- 13
- 24
4
votes
3 answers
Laravel Dusk: cannot find Chrome binary
I'm following the instructions on how to run browser tests from here https://laravel.com/docs/8.x/dusk on a fresh install of Laravel using Homestead running on a VirtualBox vm.
When I try to run artisan dusk however, it fails and tells me it can't…

Sinister Beard
- 3,570
- 12
- 59
- 95
4
votes
1 answer
laravel dusk tearDown() must be compatible with Illuminate\Foundation\Testing\TestCase::tearDown()
public function tearDown()
{
$this->browse(function (Browser $browser) {
$browser->click('#navbarDropdown')
->click('.dropdown-item');
});
parent::tearDown();
}
When I apply the…

Jiren
- 536
- 7
- 24
4
votes
3 answers
Ignore Deprecation Notice in PHPUnit 9?
I running tests using PHPUnit 9 and when I do an assertRegExp I get a Warning
assertRegExp() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertMatchesRegularExpression() instead.
How do I suppress the deprecation…

besrabasant
- 2,422
- 6
- 27
- 41
4
votes
0 answers
How can I pass arguments in to Laravel Dusk from the command line
I am using Laravel Dusk for automated browser tests by running php artisan dusk from the command line.
The website is available in English and French. Some tests depend on checking for the presence of certain strings (which may be in French or…

James Allen
- 969
- 4
- 16
4
votes
1 answer
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST with params: {"type":"browser"}
i'm setting up an phpunit test to walk trough a checkout. Now im struggling with the stripe iFrame. How can i access it?
I've created a DuskServiceProvider and registered it in AppServiceProvider.
public function boot()
{
…

Veldhaenchen
- 41
- 1
- 2