When running cucumber feature tests in Rails on WSL returns:
Failed to open TCP connection to localhost:9515 (Connection refused - connect(2) for "localhost" port 9515) (Errno::ECONNREFUSED)
After trying to run Selenium on Ubuntu without success then reading this artile Chrome doesn't start in WSL (Ubuntu 18.04) with "DevToolsActivePort file doesn't exist" under Chromedriver I tried this configuration:
Capybara.register_driver :windows_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome()
Capybara::Selenium::Driver.new(app,browser: :chrome, url: 'http://localhost:9515',
desired_capabilities: capabilities)
end
Capybara.javascript_driver = :windows_chrome
Capybara.default_max_wait_time = 5 # Seconds
- Windows 10 Version 10.0.19041.84
- Chrome installed in Windows Version 80.0.3987.106 (Official Build) (64-bit)
- Chromedriver 80.0.3987.16 in Windows 10 on port 9515
- Visiting localhost:9515 in Chrome returns: {"value":{"error":"unknown command","mes...
- Ubuntu 18.0.4
- cat /etc/resolv.conf returns: 172.19.160.1
- Ruby 2.6.3p62
- Rails 6.0.1
- capybara (3.29.0)
- selenium-webdriver (3.142.6)
- webdrivers (4.1.3)
- sudo ufw status numbered returns: Status: inactive
- Windows Firewall disabled
- Windows Defender disabled
- no antivirus running
echo 'It works' | nc -4 -v localhost 9515 nc: connect to localhost port 9515 (tcp) failed: Connection refused
echo 'It works' | nc -4 -v 172.19.160.1 9515 nc: connect to 172.19.160.1 port 9515 (tcp) failed: Connection timed out
When using 172.19.160.1 (WSL2 IP) in Capybara also get timed out.
What could be preventing the connection on port 9515?
UPDATE From this post When running WebDriver with Chrome browser, getting message, "Only local connections are allowed" even though browser launches properly
I found a work around. If I start Chromedriver like this, I can run the tests:
chromedriver.exe --whitelisted-ips=""
Not ideal; still looking for way to determine which address and ports are being used. May actually be IPV6 not IPV4?