views:

821

answers:

5

Is there an equivalent to Java's Robot class (java.awt.Robot) for Perl?

+1  A: 

There is on Linux/Unix:

http://sourceforge.net/projects/x11guitest

I'm not familiar of anything similar for Windows or Mac that uses Perl.

bmdhacks
+3  A: 

If you're looking for a way to control a browser for the purpose of functional testing, Selenium has Perl bindings: http://selenium.openqa.org/

Fhoxh
+3  A: 

For X (Linux/Unix), there's X11::GUITest.

For Windows, there's Win32::CtrlGUI, although it can be a bit tricky to install its prerequisites.

cjm
+2  A: 

On Windows, I've always used Win32::GuiTest.

Mr. Muskrat
+6  A: 

Alternatively, you can surely use the WWW::Mechanize module to create a agent as we do here at work. We have a tool called AppMon that is really just a dramatized wrapper around Mechanize.

The Mechanize module allows you to use scripts that look a lot like this:

use WWW::Mechanize;

my $Agent = WWW::Mechanize->new(cookie_jar => {});

$Agent->get("http://www.google.com/search?q=stack+overflow+mechanize");
print "Found Mechanize" $Agent->content =~ /WWW::Mechanize/;

and will result in "Found Mechanize" being output. This is a very simple script, but rest assured you can interact with forms quite well as well.

You can also move to Ruby and use Watir, but Selenium is another alternative, albeit not as interesting (in terms of coding) or automate-able. Selenium has a firefox extension that is quite useful for creating the selenium scripts and can change them between the various languages that it supports, which is pretty extensive in terms of automation.

Bob Chatman