rubywatir

Watir-webdriver - force firefox to close


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. It fires up a firefox browser through watir-webdriver.

When the computer has been running fore some hours, processing typically more than 100 jobs, the unclosed browsers start to become a problem. They take up memory and 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


Solution

  • Try this:

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