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:
- Upgrade your selenium libraries.
- 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
How Can Bundler/Gemfile Be Configured to Use Different Gem Sources During Development
How to Render File in Rails 5 API
Rails Custom Validation Based on a Regex
Simplify Multiple Nil Checking in Rails
Cannot Install Any Version of Ruby on Mojave - Internal Ranlib Command Failed
Load Two Ruby Modules/Gems with the Same Name
Rails 6: Zeitwerk::Nameerror Doesn't Load Class from Module
How to Install Rails with Jruby
Best Way to Split Arrays into Multiple Small Arrays in Ruby
Ruby: Building a Plot of Function
How to Reference a Constant in a Yaml with Rails
Travis Ci: Fatal: Role Does Not Exist
In Ruby/Rails, How to Sort on a Date Value Where the Date Can Sometimes Be Null
Error Loading Media: File Could Not Be Played Error in Jw_Player Rails