Unable to run "system" tests in Rails 5.2 when using WSL (Windows Subsystem for Linux)

I’m currently using WSL on Windows 10 for developing in Rails. So far I’ve never had any issues, but noticed I’m unable to run “system” tests.

For testing I’ve done the following:

  • “rails new sample” (created a new rails 5.2 app called sample)
  • “rails generate scaffold user first_name:string last_name:string” (created resource for running system tests)
  • rails test test/system/users_test.rb (this command produced the following)

daveomcd@LAPTOP-GDA9LTDQ:~/rails_projects/sample$ rails test test/system/users_test.rb Running via Spring preloader in process 2613 /home/daveomcd/.rvm/gems/ruby-2.4.2/gems/spring-2.0.2/lib/spring/application.rb:185: warning: Insecure world writable dir /home/daveomcd/.rvm/gems/ruby-2.4.2/bin in PATH, mode 040777 Run options: --seed 35177

Running:

E

Error: UsersTest#test_destroying_a_User: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn’t exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-17134-Microsoft x86_64) test/system/users_test.rb:38:in `block in class:UsersTest

Error: UsersTest#test_destroying_a_User: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn’t exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-17134-Microsoft x86_64)

bin/rails test test/system/users_test.rb:37

E

Error: UsersTest#test_creating_a_User: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn’t exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-17134-Microsoft x86_64) test/system/users_test.rb:14:in `block in class:UsersTest

Error: UsersTest#test_creating_a_User: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn’t exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-17134-Microsoft x86_64)

bin/rails test test/system/users_test.rb:13

E

Error: UsersTest#test_updating_a_User: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn’t exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-17134-Microsoft x86_64) test/system/users_test.rb:26:in `block in class:UsersTest

Error: UsersTest#test_updating_a_User: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn’t exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-17134-Microsoft x86_64)

bin/rails test test/system/users_test.rb:25

E

Error: UsersTest#test_visiting_the_index: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn’t exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-17134-Microsoft x86_64) test/system/users_test.rb:9:in `block in class:UsersTest

Error: UsersTest#test_visiting_the_index: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn’t exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-17134-Microsoft x86_64)

bin/rails test test/system/users_test.rb:8

Finished in 22.996091s, 0.1739 runs/s, 0.0000 assertions/s. 4 runs, 0 assertions, 0 failures, 4 errors, 0 skips

``

Can anyone tell me if this is a WSL issue? Or if I’m doing anything wrong? I’m struggling on options to debug, troubleshoot this issue. Thanks!

I’m using WSL for Rails system tests on 5.1 with rspec/capybara/selenium and ran into a similar issue.

Instead of /usr/bin/chromium-browser, my process initiating chrome was at /usr/local/bin/google-chrome. I was able to resolve the error by creating a symlink to chrome.exe on my Windows file system (in the Program Files (x86) folder). From a bash shell:

cd /usr/local/bin

**ln -s “/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe” /usr/local/bin (**create a symlink to Chrome on Windows file system. Your Chrome path may be different)

mv chrome.exe chrome (rename ‘chrome.exe’ as ‘chrome’ for selenium driver used in system tests)

Hope this helps.