Reputation: 4735
I am writing some tests and I want to see whether Dusk correctly fills in the input fields but Dusk doesn't show the browser while running the tests, is there any way to force it to do that?
Upvotes: 16
Views: 9420
Reputation: 594
Answer for Laravel 8 & UP
You can use php artisan dusk --browse
to force showing the browser.
Upvotes: 3
Reputation: 630
You can disable headless with 2 methods:
Method 1: Add this to your .env
DUSK_HEADLESS_DISABLED=true
Method 2: Add this to your special test case if you don't need to show the browser for all tests
protected function hasHeadlessDisabled(): bool
{
return true;
}
Btw, I don't know why these are not mentioned in the documentation. I found the above methods myself from DuskTestCase.php.
Upvotes: 9
Reputation: 25926
Disable the headless mode in tests\DuskTestCase.php
file driver()
function:
$options = (new ChromeOptions)->addArguments([
//'--disable-gpu',
//'--headless'
]);
Upvotes: 32
Reputation: 24083
Near the top of your tests/DuskTestCase.php
file, add:
use Facebook\WebDriver\Chrome\ChromeOptions;
In that same file, replace the entire driver()
function with:
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver() {
$options = (new ChromeOptions)->addArguments([
//'--disable-gpu',
//'--headless'//https://stackoverflow.com/q/49938673/470749
]);
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
}
Upvotes: 1