laravel / dusk

Laravel Dusk provides simple end-to-end testing and browser automation.
https://laravel.com/docs/dusk
MIT License
1.87k stars 320 forks source link

When running `php artisan dusk` the tests do not complete. They just hang. - MacOS Sonoma 14.2.1, Chip: M3 Pro #1076

Closed bobclewell closed 8 months ago

bobclewell commented 8 months ago

Dusk Version

7.7.1

Laravel Version

9.25.0

PHP Version

8.1.26

PHPUnit Version

9.5.21

Database Driver & Version

n/a

Description

When running php artisan dusk the tests do not complete. It just hangs. Sometimes I see E for some tests, but no feedback beyond that and full suite of tests has never completed.

After installing Dusk with php artisan dusk:install I've run the following, but no change... php artisan dusk:chrome-driver

Here's the ChromeDriver binary that is returned with the above "chrome-driver" command completes... ChromeDriver binary successfully installed for version 114.0.5735.90.

I've also added the following to phpunit.dusk.xml, but that hasn't returned the expected error messaging...

    <php>
        <ini name="display_errors" value="On" />
        <ini name="display_startup_errors" value="On" />
    </php>

Mac OS Sonoma 14.2.1 Chip: Apple M3 Pro

Steps To Reproduce

When running php artisan dusk the tests do not complete. It just hangs. Sometimes I see E for some tests, but no feedback beyond that and full suite of tests has never completed.

(Additional details above in the Description)

driesvints commented 8 months ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!

bobclewell commented 8 months ago

@driesvints I haven't heard anything from the StackOverflow or Laracast communities. It seems like a bug to me. Everything about my project is working correctly except php artisan dusk. I've even deployed updates to production.

For reference, my posts:

driesvints commented 8 months ago

Thanks for trying out a different channel @bobclewell. Let's see what we can do here.

Could you provide a repo that reproduces the issue?

laravel new bug-report --github="--public"
bobclewell commented 8 months ago

@driesvints Some progress. The issue appears that the version of ChromeDriver (via the Google Chrome web browser client) installed on my computer is not supported by Dusk. The error:

SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 120.0.6099.216 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

Does Dusk need an update or should I try to downgrade my Google Chrome browser client? If the latter, it's not obvious where I can get a version of Chrome that is running the v114 ChromeDriver, so any assistance there would be appreciated.

I've finally got a thread going in StackOverflow about this issue, FWIW. - https://stackoverflow.com/questions/77766234/when-running-php-artisan-dusk-the-tests-do-not-complete-they-just-hang?noredirect=1#comment137167953_77766234

driesvints commented 8 months ago

Hi @bobclewell. Like you already indicated you can install the proper version for your OS using the chrome driver command. Since you have Chrome 120 installed but you have the chrome driver 114 locally this won't work. Try running one of these commands and see if that helps:

php artisan dusk:chrome-driver --detect

php artisan dusk:chrome-driver 120

Also see https://laravel.com/docs/10.x/dusk#managing-chromedriver-installations

bobclewell commented 8 months ago

@driesvints There doesn't appear to be a v120 of the GoogleDriver available.

file_get_contents(https://chromedriver.storage.googleapis.com/LATEST_RELEASE_120): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
driesvints commented 8 months ago

There does: https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone-with-downloads.json

From 115 and up it uses a different way to determine the downloads. I really wonder why php artisan dusk:chrome-driver 120 doesn't works for you because the version is in the json above.

bobclewell commented 8 months ago

I think I fixed it. I ran:

composer require laravel/dusk --with-all-dependencies

Dusk was already installed, but my composer.json updated in this way...

-        "laravel/dusk": "^7.7",
+        "laravel/dusk": "^7.12",

Then...

php artisan dusk:chrome-driver --detect

...installed the v120 driver.

So, I now appear to have the correct driver. My tests are still showing errors and failures, but I think this is related to the root URL configured and I can try to work out this issue on my own. Feel free to close this issue, or let me know if you have any questions.

driesvints commented 8 months ago

This fix was introduced in v7.9.0 so yeah that's it. I didn't caught that you were using an old version. Always make sure you're up to date with the latest version before you post an issue. Glad you found it 👍

https://github.com/laravel/dusk/blob/7.x/CHANGELOG.md#v790---2023-07-24