2

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
        );
    }
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Matthieu
  • 437
  • 6
  • 16

1 Answers1

1

This error message...

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

...implies that the NoSuchElementException was raised during your program execution.


A bit of details about your Test Configuration interms of chromedriver version would have helped us to debug your issue in a better way. However you need to take care of a couple of things:


Reference

You can find a relevant detailed discussion in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Hats off to your time and effort.Most people likely avoid such longer question and It seems you have all the time and answer whenever there is any problem related to selenium.Such a dedicated contributor +1 – KunduK Jan 12 '20 at 13:06
  • Thanks indeed for the help so far. I'm not sure if I understand your remark 'A bit of details about your Test Configuration in terms of chromedriver version '. Isn't the error showing it is using 75.0.3770.90 ? As you state that there is a newer version I'm now trying to use v79. At the moment I did a pull on Laradock and are rebuilding. I will see if that is going to solve any issues. I understand about the NoSuchElement error, but the problem is that the element is there. Somehow it is not found. – Matthieu Jan 12 '20 at 13:19
  • @Matthieu `headless chrome=75.0.3770.90` implies **chrome** _Browser_ version. Whereas `Driver info: driver.version: unknown` at some point **chromedriver** version was not detected. – undetected Selenium Jan 12 '20 at 13:24
  • Could that be a clue that it is unknown there? The Selenium Webdriver hub says it using chromedriverVersion": "75.0.3770.90. Seem to be stuck though on updatin to v79. – Matthieu Jan 12 '20 at 15:34
  • No, **75.0.3770.90** is the `chrome=75.0.3770.90` version and can't be the **chromedriver** version. – undetected Selenium Jan 12 '20 at 15:51