3

Perl 是否有与 Java 的 Robot 类 (java.awt.Robot) 等效的东西?

4

5 回答 5

6

Alternatively, you can surely use the WWW::Mechanize module to create an 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.

You can also move to Ruby and use Watir, or Selenium as 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.

Update - Nov 2016

Although I haven't had much of an opportunity to play with it, there are also webdriver packages for most languages, and Perl is no different.

Selenium::Remote::Driver

于 2008-09-17T20:11:51.957 回答
4

如果您正在寻找一种方法来控制浏览器以进行功能测试,Selenium 具有 Perl 绑定:http ://selenium.openqa.org/

于 2008-09-17T04:30:09.583 回答
3

对于 X (Linux/Unix),有X11::GUITest

对于 Windows,有Win32::CtrlGUI,尽管安装它的先决条件可能有点棘手。

于 2008-09-17T05:56:06.663 回答
2

在 Windows 上,我一直使用Win32::GuiTest

于 2008-09-17T14:26:13.987 回答
1

在 Linux/Unix 上有:

http://sourceforge.net/projects/x11guitest

对于使用 Perl 的 Windows 或 Mac,我不熟悉类似的东西。

于 2008-09-17T04:26:36.893 回答