0

I`m having issues with phantomjs with my parallel testing, firefox is running fine. I use parallel_tests, watir-webdriver, and Cucumber.

No connection could be made because the target machine actively refused it. - connect(2) for "127.0.0.1" port 8910 (Errno::ECONNREFUSED)

Tests are running via:

parallel_cucumber features/parallel_tests -n 3

After some debugging I figured the problem appears when first process is finished with testing, it somehow kills all phantomjs browser instances.

This is env.rb setup:

browser = Watir::Browser.new :phantomjs, args: %w(--ignore-ssl-errors=true)

Before do
  @browser = browser
  @browser.cookies.clear
end

at_exit do
  browser.close
end

I also tried not closing browser at all, but with no luck, it is somehow done automatically. I tried both Windows, and CentOS.

phantomjs -v 
2.0.0
Using cucumber 1.3.19
Using selenium-webdriver 2.45.0
Using watir-webdriver 0.6.11
Using parallel 1.4.1
Using parallel_tests 1.3.9

I have a feeling it is a phantomjs/webdriver bug...

cvakiitho
  • 1,377
  • 13
  • 27

1 Answers1

1

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.

Community
  • 1
  • 1
Johnson
  • 1,510
  • 8
  • 15
  • 1
    I read that question, it will probably be something simillar, but the problem is not with starting the phantom, but with killing it. Tests run fine for 3 minutes, but when 1st process is finished it kills all phantoms. – cvakiitho May 20 '15 at 09:17
  • Ok, So I tried `sleep ENV['TEST_ENV_NUMBER'].to_i`, and this time only the last tests failed. ... some more testing, I added it to two places, and it passed... weird... – cvakiitho May 20 '15 at 09:32
  • So you were right, but my env.rb had something before browser setup, so even 1s sometimes wasn`t sufficient,anyway THANKS A LOT!!! – cvakiitho May 20 '15 at 09:39