Sam
Sam

Reputation: 1253

Watir-Webdriver EOFError and Errno::ECONNREFUSED

While running a DelayedJobs queue that uses Watir-Webdriver (with Headless and Firefox) to get some data off the web a few times per hour, I am encountering random EOFError and ECONNREFUSED errors.

It's a reasonably simple script that goes to a site, logs in, enters data in a form and verifies the data returned. However, the errors occur seemingly at random at any point in the script. You can see examples of that below. I think it's also relevant to note that a separate app is running within the same machine, also using Headless, Watir-Webdriver and Firefox.

Because of the randomness, the alternate app, and because Googling led me to this issue with Selenium and ports causing the EOF issue at random, I'm inclined to believe that this is an issue where running Selenium-driven Firefox (via Watir) at the same time is the root cause. So my questions are:


EOFError examples

For instance, EOFError: end of file reached happens here when trying to .goto:

/home/sam/.rvm/gems/ruby-2.0.0-p353/gems/watir-webdriver-0.7.0/lib/watir-webdriver/browser.rb:77:in `goto'

then on .text:

/home/sam/.rvm/gems/ruby-2.0.0-p353/gems/watir-webdriver-0.7.0/lib/watir-webdriver/elements/element.rb:83:in `text'

ECONNREFUSED examples

Here, Errno::ECONNREFUSED Connection refused - connect(2) happens on .set:

/home/sam/.rvm/gems/ruby-2.0.0-p353/gems/watir-webdriver-0.7.0/lib/watir-webdriver/user_editable.rb:11:in `set'"

then on .click:

/home/sam/.rvm/gems/ruby-2.0.0-p353/gems/watir-webdriver-0.7.0/lib/watir-webdriver/elements/element.rb:119:in `click'

Stack:

Upvotes: 1

Views: 355

Answers (2)

Sam
Sam

Reputation: 1253

I had success giving each app it's own Xvfb display:

On the server itself:

$ sudo /usr/bin/Xvfb :98 -screen 0 1280x1024x24 -ac &
$ sudo /usr/bin/Xvfb :99 -screen 0 1280x1024x24 -ac &

App 1 - before the browser is being created:

# ~/repo1/whatever.rb
# ...
h = headless(:display => '98')
# ...

App 2 - before the browser is being created:

# ~/repo2/something.rb
# ...
h = headless(:display => '99')
# ...

@chuck-van-der-linden is probably correct, though, that using VMs or similar are a better solution. If I was starting fresh with this architecture, this would be my approach.

Upvotes: 0

Chuck van der Linden
Chuck van der Linden

Reputation: 6660

If either test is perfectly reliable when run alone, then I think your presumption about running them in parallel is likely correct.

I would either run them serially one after the other, or try to find some other way to better separate them.. perhaps using something like tanker and running the tests inside linux containers? (if you are running on linux)

Upvotes: 1

Related Questions