Category Archives: WATIR

Exception class/object expected (TypeError) on starting FireWatir

If you get the following… /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/firefox.rb:1078:in `raise’: exception class/object expected (TypeError) from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/firefox.rb:1078:in `js_eval’ from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/firefox.rb:195:in `get_window_number’ from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/firefox.rb:162:in `initialize’ from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/firefox.rb:177:in `new’ from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/firefox.rb:177:in `start’ …the problem is that firefox is already running, probably with a dialog box open. … Continue reading

Posted in Automated Testing, Ruby, WATIR | Tagged , , , , , | Leave a comment

Finding a form by xpath in Firewatir causes ‘Stack Level Too Deep’

If in a firewatir script you look for a form using xpath, you’ll get the following output: SystemStackError: stack level too deep from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/htmlelements.rb:72:in `locate’ from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:1012:in `exists?’ from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:965:in `assert_exists’ from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:1403:in `method_missing’ from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/htmlelements.rb:75:in `locate’ from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:1012:in `exists?’ … Continue reading

Posted in Automated Testing, WATIR | Tagged , , , | Leave a comment

How to quit Firefox using FireWatir on a Mac

There seems to be a bug in the way that FireWatir on the mac quits firefox… it doesn’t! When you try, you end up with a dialog box saying: Close Firefox A copy of Firefox is already open. Only one … Continue reading

Posted in Automated Testing, Example Code, Ruby, Tools, WATIR | Tagged , , , , , , | Leave a comment

How to know if you have a secure session in Watir

Sometimes you’re on a secure page, sometimes you’re not. How to know? There’s a very simple method you can write to find out, based on the browser’s current url. Here’s the method: def is_session_secure? @browser.url =~ /^https/ ? true : … Continue reading

Posted in Example Code, Ruby, Test::Unit, WATIR | Tagged , , , , , , | Leave a comment

How to get only direct child objects in Watir

When you come across methods in watir that return child objects for the first time (eg: the ‘lis‘ in @browser.ul(:id,’main’).lis ) you’d think they’d return only the direct child objects. Frustratingly, they don’t. They’ll also return nested objects of the … Continue reading

Posted in Automated Testing, Example Code, Making Life Easier, Ruby, Tools, WATIR | Tagged , , , , , | Leave a comment

How to check for errors on every page using Watir

Testing a web app in an unstable environment is a pain. Many tests will fail for environmental reasons and filtering out those results can take a while. To make this sort of thing less painful, Watir and its derivatives (eg: … Continue reading

Posted in Automated Testing, Example Code, Making Life Easier, Ruby, Tools, WATIR | Tagged , , , , , | 1 Comment

Fix for Firewatir visible? method

The visible? method in the ruby Firewatir 1.6.2 gem isn’t great. After some hunting around, I ended up here and found a working monkeypatch. Here’s the code: class Element def visible? assert_exists jssh_command = "var val = ‘true’; var str … Continue reading

Posted in Automated Testing, Example Code, Ruby, Tools, WATIR | Tagged , , , , , , , | Leave a comment