I'm running Dusk to test my Laravel application. I've recently switched to Laradock which took some time to set it all up as I have little experience with Docker, but it all seems to be working now. Except that Selenium doesn't seem to be working as it should.
I start and open my workspace like this:
sudo docker-compose up -d nginx postgres beanstalkd selenium
sudo docker-compose exec --user=laradock workspace bash
and then
php artisan dusk
1) Tests\Browser\SuccessLoginTest::test_user_can_login
Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body textarea[name='email']"}
(Session info: headless chrome=75.0.3770.90)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'f8c1169cd1a3', ip: '172.18.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.7-100.fc30.x86_64', java.version: '1.8.0_212'
Driver info: driver.version: unknown
I get a screenshot of the failing test showing the websiteand on it the and element it can't seem to find. Before I switched to Laradock everything was working properly, so the problems seems to be with Selenium. My setup looks like this and I use Laravel 5.7.28
protected function driver()
{
$options = new ChromeOptions();
$options->addArguments([
'--headless',
'--no-sandbox',
'--disable-gpu',
'--window-size=1920,1080',
'--ignore-certificate-errors'
]);
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
if (env('USE_SELENIUM', 'false') == 'true') {
return RemoteWebDriver::create(
'http://selenium:4444/wd/hub', $capabilities
);
} else {
return RemoteWebDriver::create(
'http://localhost:9515', $capabilities
);
}