How to tell Laravel Dusk to use Chrome-for-testing (CFT) browser rather than the regular installed version of Chrome

On MacOs

Dusk Version -8.2.5

Laravel Version – 10.35.0

PHP Version – 8.2.13

PHPUnit Version – 10.5.2

I’ve been using the Chromedriver from Chrome-for-Testing with Laravel Dusk to test our app. Until recently I had been testing against the version of the regular Chrome browser installed on my machine. That worked fine until the version of chromedriver available was out of sync with the version of my regular chrome browser and I got the dreaded Failed to connect to localhost error

Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":["--window-size=1920,1080"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","goog:chromeOptions":{"args":["--window-size=1920,1080"]}}}
Failed to connect to localhost port 9515 after 1 ms: Couldn't connect to server

The answer as I understand it is to grab the matching version of CfT browser to test against, e.g. get the 128.0.6613.137 ChromeDriver and 128.0.6613.137 CfT browser.

I did that but I have not been able to get Dusk to use that CfT browser.

What I tried

I set the Binary location (which I think is to the CfT browser location as opposed to the Chromedriver location) to DuskTestCase.php > driver method;

$options->setBinary(‘/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing’);

The result (error)

All my tests still fail with a curl error;

Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"binary":"/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing","args":["--window-size=1920,1080"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","goog:chromeOptions":{"binary":"/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing","args":["--window-size=1920,1080"]}}}
Failed to connect to localhost port 9515 after 0 ms: Couldn't connect to server

Other things I tried

I tried changing the path to an obviously incorrect path and I get the same error. I tried omitting the path to the CfT browser binary and I get the same error

Other thoughts

This might not be an issue of chromedriver and browser being out of sync. This started with the “The failed to connect to localhost” error and in the past that was because the chromedriver and installed chrome browser were out of sync. I’m assuming that if I get the ChromeDriver and Chrome Browser in sync the issue will be resolved. But its a bit strange that when I set an obviously incorrect path to the CfT browser I dont get an error.

I too had been facing the same issue with my dusk tests. After a lot of looking around I finally found this PR on the repo: https://github.com/laravel/dusk/pull/1124.

In my DuskTestCase.php I am manually calling the static::startChromeDriver() so I needed to implement the same change in my call and specify the port: static::startChromeDriver(['--port=9515']);

Not sure if this is the same for you, but might be something to look at.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật