How to remotely control Firefox from a script on OSX

taw picture taw · Apr 14, 2009 · Viewed 7.8k times · Source

I need to write some scripts that access some websites. A script from command line would get some pages, post some forms, screen scrap some information etc.

It cannot really be a library "browser" like libwww-perl because some steps might require user interactions (captchas, ajax-only forms, any interaction surprises etc).

The most practical way I can think of would be remotely opening a tab in Firefox, and injecting Javascript into it, something a bit like what Greasemonkey and Selenium do. It doesn't necessarily have to be for Firefox, can be a different browser if that's easier.

So what would be the best way to do that?

Answer

Alex B picture Alex B · Apr 14, 2009

Have you considered Selenium Remote Control? I've automated browser interaction using the tool before and it works very well, providing a lot of flexibility

Depending on your exact needs, you might be able to leverage the Selenium IDE which is an easy to use Firefox plugin that allows easy scripting.