1
votes

I'm the frequent user of watir-webdriver. A fantastic gem, but I have an increasing issue with browsers that newer get closed. I run an ubuntu machine, that processes some background tasks, that fires up a firefox browser through watir webdriver. When the computer has been running fore some hours, processing typically more than a 100 jobs, then uncloses browsers start to become a problem. They take up memory, an eventually jams the computer forcing me to restart.

The problem occurs even though I do something like:

begin
  b = Watir::Browser.new :firefox, :profile => 'default'
  # Goto a few pages
  b.close
rescue => e
  b.close
  raise e
end

Any idea what I can do to solve it? is there a way to ensure that the processes are forced to quit if an exception occurs? And how I can debug it?

I often see a some timeout exceptions saying unable to bind to locking port or unable to obtain stable connection.

BTW ruby 1.9.3, ubuntu 12.04 watir-webdriver 0.6.1

2

2 Answers

2
votes

Try this:

begin
  b = Watir::Browser.new :firefox, :profile => 'default'
  # Goto a few pages
ensure
  b.close
end
0
votes

You might want to investigate headless solutions, such as the headless gem or Celerity.

The headless gem still drives a browser, just not on a display. Celerity, however, wraps HTMLUnit which is a virtual browser with decent javascript support. I've been using Celerity to run automated tests and it has been robust. The main caveat is that it is JRuby only.

Another option would be to use a leaner browser, such as webkit.