views:

282

answers:

2

I'm building a Ruby program that uses several other programs, and while most of them are programs I can download and run on this computer, one has to be accessed and run through a web browser.

I actually have two questions: I've found Watir which looks like a good web automation tool, but it's meant for testing. Is it still okay to use Watir for automation in the main program, not for testing? Or is there something better out there to use?

The other question I have is that I can't get Watir to work. I downloaded the firewatir-1.6.5 gem and installed jssh for Firefox 3.6, but when I run

b = Watir::Browser.start("the_web_page_address")

it just opens a new Firefox window to Google, and I'm given the error:

Unable to connect to machine : foo.bar.baz.blah on port 9997. Make sure that JSSh is properly installed and Firefox is running with '-jssh' option (Watir::Exception::UnableToStartJSShException)

I've run Firefox with -jssh but that doesn't seem to help.

+2  A: 

Watir is perfectly suitable for automating browsing tasks. I've personally used it a couple of times for that purpose. However, you might also want to look at other solutions, such as Selenium.


Now, to be honest, I don't have much to say about your second question; I'm assuming you've set Watir to open firefox by setting

Watir::Browser.default = 'firefox'

If so, things should be running as normal. Did you restart firefox since installing jssh? Did you install Watir and jssh as instructed on the tutorial?

I can suggest running Watir with Internet Explorer, instead of Firefox, but that might be unsuitable for your application. If all else fails, try the other framework I recommended earlier.

Justin L.
+2  A: 

You also might want to check out a headless option. Sometimes it's not necessary to install an automation framework like Watir or Selenium when something simple like mechanize would suffice. Really depends on the complexity of what you're trying to automate!

http://mechanize.rubyforge.org/mechanize/EXAMPLES_rdoc.html

Tim Koopmans