I'm developing my Rails application in a WSL environment on Windows 11.
I use VS Code for my editor, and use the WSL - Remote extension to connect to the WSL filesystem, edit my app, etc.
When I run rake test:system
I get:
blaine@blaine_ems_dev:~/myapp$ rake test:system
rake aborted!
Webdrivers::BrowserNotFound: Failed to find Chrome binary.
/home/blaine/myapp/test/application_system_test_case.rb:7:in `<class:ApplicationSystemTestCase>'
/home/blaine/myapp/test/application_system_test_case.rb:3:in `<main>'
/home/blaine/myapp/test/system/customer_administration_stories_test.rb:1:in `<main>'
Tasks: TOP => test:system
(See full trace by running task with --trace)
Neat thing is, I can open Chrome via WSL by issuing this command:
/mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe
Is there some way I can simply plug in the path to the Windows binary I have installed, and have it run my system tests?
Or perhaps there's a better way altogether?
CodePudding user response:
You can override webdrivers attempt to detect the location of Chrome by setting Selenium::WebDriver::Chrome.path
to the location of your Chrome binary or you can set the WD_CHROME_PATH
environment variable.
CodePudding user response:
Under WSL, you are running the Linux version of Ruby, which won't be able to communicate via WebDriver with the Windows Chrome executable.
Similar to this Python/Selenium/WSL2 question, you'll need to install the Linux Chrome executable.
Since you have Windows 11, that shouldn't be a problem since it supports running GUI apps through WSLg. I've successfully run Selenium using xrdp
with Python on Windows 10, and I just ran ruby2d
for another Ask Ubuntu question on Windows 11 using WSLg, so I'm fairly confident this will work for you.