Please also support firefox driver.
I have encountered a problem that mouseover does not work.
https://medium.com/@melihovv/how-to-use-laravel-dusk-with-selenium-and-firefox-9c12cdf92c94
This document will be used as a reference.
If you have a firefox driver, you're more comfortable.
I created a branch that allows Laravel Dusk to support geckodriver (formerly Firefox Driver) without additional configuration: https://github.com/laravel/dusk/compare/6.x...derekmd:firefox-support
php artisan dusk:install --firefox
will copy a tests/DuskTestCase.php into your application that will open Firefox via Geckodriver running at http://localhost:4444/. No Selenium installation is required.
GET_LOGFirefox doesn't implement the WebDriver API to retrieve console.log output for JavaScript debugging. $driver->manage()->getLog('browser') can't return output so Dusk wouldn't be able to a store an _individual_ tests/Browser/console/*.log file for each browser run.
However it is possible to awkwardly get the console output via the geckodriver server's stdout. This .log file will cover _all_ browsers run during a single test.
RemoteWebDriver::create(
'http://localhost:4444',
tap(DesiredCapabilities::firefox(), function ($caps) {
$caps->getCapability(FirefoxDriver::PROFILE)
->setPreference('devtools.console.stdout.content', true);
})
);
A ProvidersBrowser::afterClass() hook can then store the stdout string returned by SupportsFirefox::$firefoxProcess->getOutput(). This requires a significant refactor of Browser::$storeConsoleLogAt that would likely be a breaking change.
As seen in https://github.com/mozilla/geckodriver/releases notes, there are known issues with automating installations. Windows also needs "Microsoft Visual Studio redistributable runtime" to be manually installed separately. The new php artisan dusk:firefox-driver command has these instructions added.
Geckodriver on Windows requires installing Microsoft Visual Studio redistributable runtime.
Download binaries at https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
Until the JavaScript console log issue can be cleared up, I don't think this will make it into Dusk.
@derekmd thank you so much for looking into this. First of all I want to say that I think it's best that we stop shipping the executables with dusk as they tend to increase the package size by quite a lot. I'm actually thinking of removing the chrome executables in a next major version as well which will require people to always install them with the driver commands.
As for the rest of the PR, I agree that we might best wait until the JavaScript console log issue is resolved. I'll keep this open for the time being but for now it's best that we wait.
wait until the JavaScript console log issue is resolved
@driesvints: Investigating further, according to Mozilla developer comments in 2018 and 2019, it's a "hard no" on Firefox supporting $driver->manage()->getLog('browser') that Laravel Dusk calls when Chrome or PhantomJS browsers are used. This is considered a Selenium spec, outside the scope of the W3C Webdriver API.
References:
With no active W3C spec discussions or Firefox dev work being done to add commands.GetLog to the WebDriver API, the only mechanism Geckodriver consumers are left with is stdout logging.
To support Firefox, I see these three options with escalating implementation complexity:
SupportsFirefox trait method that exposes the SupportsFirefox::$firefoxProcess->getOutput() returned string for userland debuggers to call dump($this->getFirefoxOutput()) after a $this->browse() Closure.Laravel\Dusk\TestCase sibling traits need to share state through static methods and it's very ugly.Thanks for all the research @derekmd. We've decided to not support Firefox for the time being. I'll pin this issue for anyone who wants to know the reasoning.
I've published that "laravel/dusk" dev branch as a standalone package: https://github.com/derekmd/laravel-dusk-firefox
Run these commands to start using Firefox instead of Google Chrome:
composer require --dev derekmd/laravel-dusk-firefox
php artisan dusk:install-firefox
php artisan dusk
It's also possible to run tests in either browser. See the package's Github docs for more details.
Most helpful comment
I've published that "laravel/dusk" dev branch as a standalone package: https://github.com/derekmd/laravel-dusk-firefox
Run these commands to start using Firefox instead of Google Chrome:
It's also possible to run tests in either browser. See the package's Github docs for more details.