views:

1328

answers:

11

I'm trying to streamline some of our tasks at my place of work, and it seems that quite a lot of our developers' time is spent doing semi-mechanical tasks on the web (specifically, editing online stores that use web-based interfaces). As such, I've been looking into some solutions that will allow these tasks to be done by scripts since I figure that could save us quite a bit of time per task. So before I really started digging into any of these, I was just wondering if the Stack Overflow community had any recommendations about which web scripting/macro solution would be the best.

Here are the requirements:

  • Must be able to interact with web forms (not just downloading a page and scraping the file - the script must edit controls within a web form and then submit that form)
  • The forms we have to edit are secure forms, so the scripting solution must be able to handle that (ie it's of no use for us to have an incredibly powerful scripting solution if a human being will have to sit there and watch it and manually re-login every few minutes)
  • It would be really, really, really preferable if it could read local files and do some basic string replacement/manipulation on them (e.g. it would be nice to have a list of variables or some HTML code in a text file and then have the script replace the token "STORENAME" with that particular store's name before it inserts the code into the form)

Here are the scripting solutions that are on my radar so far (I haven't really looked into any of these, although I have played around with Chickenfoot):

  • Chickenfoot
  • iMacros for Firefox
  • libwww-perl
  • libwww for unix and C (while searching for libwww for perl I came across this, which I did not know existed until now)
  • a more "general" macro solution like AutoHotKey

Has anyone here on Stack Overflow tried any of these solutions? If so, what did you like or dislike about them? Can anyone recommend one that is not on the list? (This is by no means an exclusive or exhaustive list). I would really love to automate a lot of our mechanical processes, and I hope the Stack Overflow community can help us out so we can hopefully avoid that much of the mind-numbing part of the work :). Thanks in advance!

edit: Re: platform - We have primarily WindowsXP terminals at work, but 1) we do have a few Mac test PCs, so OS X is a viable option, and 2) if it would mean automating a lot of these tasks, I'll build a Linux box if that is necessary. So platform is pretty much a non-issue.

+2  A: 

I really like the watir framework (running on ruby) -- programmable, easy, uses IE to automate the Web (and so you get true browser behavior). Of course, it's Windows only -- you didn't specify whether that's what you use.

We've used watir to automate our tests of a webapp, and we're very satisfied.

Asaf Bartov
+2  A: 

@Asaf Bartov, actually, Watir is not Windows only. There are also FireWatir that works on Windows, Linux and Mac, and SafariWatir that works on Mac.

http://wtr.rubyforge.org/ http://wiki.openqa.org/display/WTR/FireWatir http://safariwatir.rubyforge.org/

Željko Filipin
+2  A: 

A few suggestions:

Edit: I'm assuming these would act on web pages containing the data you want to submit to the forms.

Sam Hasler
Greasemonkey doesn't seem to really fit the problem. Greasemonkey is great for "when such and such a page loads, run this javascript," whereas what I'm looking for is something along the lines of "enter this in this form, then click submit, then go to this other form, enter this other stuff, etc."
Jordan
I was thinking that if you could get the data you want to submit onto a web page, you could use GreaseMonkey to submit it to the form. (I'm assuming you'd need it to do a cross site xmlhttprequest)
Sam Hasler
I never thought of that; kudos on the inversion of the problem. Though if I was at the point where that was a serious option, I'd probably look at Chickenfoot first, since it supports some of the GM API and is more suited to my mental model of the problem ("go to this URL, click this, submit that")
Jordan
+1  A: 

If you're using libwww-perl, then don't stop there. Use WWW::Mechanize, which is a wrapper around LWP that does the browser interaction you want. The downside: It doesn't handle JavaScript (yet).

WWW::Mechanize home page

Andy Lester
Awesome - thanks for the link. I'll definitely look into that, but I'll have to just dip a big toe in first in light of the javascript caveat (which I also thank you for mentioning).
Jordan
+2  A: 

I'm actually a big fan of Chickenfoot, which I have started using a lot recently to provide scripting capabilities for Zotero, another Firefox extension.

Raymond Yee
+3  A: 

Another option is use AutoIT + Firefox + mozrepl + FF.au3. This is powerful as AutoIT operates outside the browser (it's a fantastic automation tool in itself) so you can work through submitting multiple browser forms without losing context. Then the FF.au3 script lets you simply control Firefox via AutoIT3.

Alex Angas
+1  A: 

Hi, we use the iMacros tool you mentioned with good success:

Firefox + iMacros

Note that it also comes as free IE addon! The great thing about this is that the exactly same macros work in both browsers. IMHO very useful for quick and easy web testing and general web automation.

Tim

+1  A: 

Use:

Firefox + iMacros to fetch:
Go to the page you like (e.g yahoo.com), bring iMacro in focus, hit record and search for some text. When first page shows, Save the page in a file.

Now you have a page you wanted.
You are done fetching at this point.
Save the macro and give it a name. Next time you can just run the macro you just saved.

You then clean up the html code you got by using this:

# this is php, do the proper thing in the language of your choice
# one or more spaces is equal to one space, remove tab, return  ...etc.
return ereg_replace(' +', ' ', trim(preg_replace("/(\r\n|\r|\t|\n|\'|\")/s", '', $string)


Now you have a clean html page with one line, a long one.
Now you can cut and slice as you wish by using a regEx.

Things to know:
You can start the macro in firefox via a cronjob (commandline) if you need full automation.

VN44CA
+1  A: 

my impression of IMacros is you need to pay to unlock a lot of the goodies, so I went with Chickenfoot. Unfortunately the Chickenfoot mailing list is very quiet lately, so am not confident about its future...

Plumo
A: 

I'm using iMacro/.net for a data extraction project. I like the ease of scripting for iMacros, which is important since the application may have up to 60+ websites to extract data from. For this project the overhead cost of running iMacros is worth the saved development time. It's not the ideal solution, but it's one way to interface with another website's data, assuming they don't provide a proper interface. The neat part is that I've created a small server cluster of iMacros scrapers to help distribute the load. Right now users can access the application servers through a website for adhoc requests, but eventually i'd like it to evolve into something more streamed line.

Kevin
+1  A: 

I'm a big fan of Selenium

http://www.seleniumhq.com

designed to handle automated browser testing though with scripting support (multiple languages) you can design macro templates that will fill in forms and such based on variables

also: anyone know a good macro that works with Flash?? Doesn't seem javascript is able to cross that line

Alvin