3

We recently decided our project is getting too large to function well without automated tests.
While trying to write our first Laravel Dusk test for the project I found the test failing without a clear reason.

First I noticed a weird line about the SSL handshake failing but after a little bit of searching, this error wasn't getting me anywhere.

ssl client socked handshake failed

After a while, I found the option to run dusk in a way it showed the browser and its actions. Turns out my test was failing because the page it was visiting was never shown because of chrome's "Your connection is not private" page.

enter image description here

Then I found this post from 2017 https://laravel-news.com/chrome-63-now-forces-dev-domains-https
According to this post chrome shouldn't show this page when you are using .localhost or other unused domain extensions, I have tried the extensions .local .localhost & .test but none were successful.

Is there a way to tell chrome I don't want to see this page?

Razneesh
  • 1,147
  • 3
  • 13
  • 29
mark DE Jong
  • 257
  • 2
  • 17

2 Answers2

7

This answer to a similar question regarding using Selenium/ChromeDriver with Python points to the solution.

You need to create your ChromeDriver with the following flags:

--ignore-certificate-errors
--ignore-ssl-errors

For Laravel Dusk these are set in DuskTestCase::driver() (DuskTestCase.php is in the tests\Browser directory)

Jim L
  • 476
  • 4
  • 15
2

To expand on the other answer, which didn't provide enough detail for me, this is fixed by editing tests/DuskTestCase.php to add the --ignore-certificate-errors command-line switch:

   $options = (new ChromeOptions)->addArguments(collect([
       '--window-size=1920,1080',
       "--ignore-certificate-errors",
   ])->unless($this->hasHeadlessDisabled(), function ($items) {
         return $items->merge([
          '--disable-gpu',
          '--headless',
      ]);
   })->all());

Note that only the --ignore-certificate-errors option seems to be required - as far as I can tell --ignore-ssl-errors currently has no effect at all, at least for this issue.

Hashim Aziz
  • 4,074
  • 5
  • 38
  • 68