Opening Several Threads with Watir-Webdriver Results in 'Connection Refused' Error

Opening several threads with watir-webdriver results in 'Connection refused' error

You're basically creating a race condition between the instances of your browser to connect to the open port watir-webdriver is finding. In this case, your first instance of the browser sees that port 9517 is open and connects to it. Because you're spinning up these instances in parallel, your second instance also thinks port 9517 is open and tries to connect. But oops, that port is already being used by the first browser instance. That's why you get this particular error.

This also explains why the sleep 2 fixes the issue. The first browser instance connects to port 9517 and the sleep causes the second browser instance to see that 9517 is taken. It then connects on port 9518.

EDIT

You can see how this is implemented with Selenium::WebDriver::Chrome::Service#initialize (here), which calls Selenium::WebDriver::PortProber (here). PortProber is how the webdriver determines which port is open.

Parallel-test Cucumber watir testing with phantomjs ECONREFUSED

This is likely a race condition to port 8910 by your 3 phantom instances. Similar to this issue.

# env.rb
Before do
sleep ENV['TEST_ENV_NUMBER'].to_i
@browser = Watir::Browser.new :phantomjs, args: %w(--ignore-ssl-errors=true)
end

If I'm reading the ParallelTests source correctly, environment variable TEST_ENV_NUMBER is set to the process index for each process. So the first process has a TEST_ENV_NUMBER of 0. As long as that's the case, the Before hook above will sleep for that number of seconds before initializing Watir::Browser. That will stagger the the parallelization a bit, but it should remove the race condition.

Using RSpec, Capyabra and Selenium (docker), on click method getting error: Connection refused

It happened to me many times. And the answer is:

  1. Upgrade your selenium libraries.
  2. Upgrade your container image and recreate the container.

In summary make sure your versions are in sync with the container versions.

Also be aware of Selenium 3.0 in my case it didn't work so well in firefox, so I downgraded my libraries and the container to stick selenium 2.53

Regards

Ruby/Selenium/Watir-Webdriver: path is not absolute error for absolute path

That error comes from Chromedriver, and comes from sending an incorrect path string to a file element. Since :tab is not a path, it is correctly raising an error.

You shouldn't need to send a tab; just sending the path of the file should accomplish what you need.



Related Topics



Leave a reply



Submit