Win32::Watir - Perl extension for automating Internet Explorer.
use Win32::Watir; # Creating new instance of Internet Explorer my $ie = Win32::Watir::new( visible => 1, maximize => 1, ); # show google, search 'Perl Win32::Watir' keyword. $ie->goto("http://www.google.co.jp/"); $ie->text_field('name:', "q")->setvalue("Perl Win32::Watir")
Win32::Watir helps you to write tests that are easy to read and easy to maintain.
Watir drives browsers the same way people do. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page.
Win32::Watir is inspired on Ruby/Watir, then fork Win32::IEAutomation.
Win32::IEAutomation special nice interface at perl and windows, but some method doesn't support IE7, IE8 for Window/Dialog name changes. Win32::Watir are support IE7, IE8 and use more compatible/like Ruby/Watir method names, ..etc.
* Ruby/Watir : http://wtr.rubyforge.org/
* Win32::IEAutomation : http://search.cpan.org/perldoc?Win32::IEAutomation
you may require setup Multiple_IE when using this with IE6.0
options are supported to this method in hash format.
warnings => 0 or 1 0: output no warning. 1: output some warnings. maximize => 0 or 1 0: default window size. 1: maximize IE window when IE start. visible => 0 or 1 0: IE window invisible. 1: IE window visible. codepage => undef or 'utf8' undef: use default codepage at your Windows. utf8 : use Win32::OLE::CP_UTF8 codepage. ie (IE executable path) : specify your multiple IE executable path. ex) c:/path_to/multipleIE/iexplorer.exe find : If "find" key exists, find IE window in current workspace
if no options specified, use those default.
$ie = new Win32::Watir( warnings => 0, maximize => 0, visible => 1, codepage => undef, );
close IE window.
Site navigate to specified URL.
ex). go cpan-site. $ie->goto('http://search.cpan.org/');
IE window back. same as "back button" or type Backspace key.
reload, refresh IE page. same as type 'F5' key.
return current page URL.
return current page title.
return current page html.
notice: "CR" code (\r) removed from html.
verify current document include specified "text" .
text : string flag : 0 (default) 1 (?) [ToDO] check createTextRange()
return current page as Plain TEXT which removed HTML tags.
Finding hyperlinks.
ex). Using 'linktext:' option (text of the link shown on web page) $ie->getLink('linktext:', "About Google")->Click;
Using 'linktext:' option with pattern matching $ie->getLink('linktext:', qr/About Google/)->Click; Using 'id:' option ( <a id=1a class=q href=......>) $ie->getLink('id:', "1a")->Click; Using 'href:' option ( <a href=......>) $ie->getLink('id:', qr/search.cpan.org/)->click;
return all array of link_object.
ex). print pagename at google search result. foreach my $ln ( $ie->getAllLinks ){ print $ln->text."\n" if ($ln->class eq 'l'); }
finding input buttons.
finding img.
return array of all image tag.
return input radio object.
return input checkbox object.
return input (type=text) object.
return textarea object.
return all array of div tag.
return AutoItX3.Control
make IE window active.
return IE major version (6 or 7 or 8).
Register specified dll to Server.
arg[0] : dll path.
push "Yes" button at "Security Alert" dialog window.
wait: number of sec, for waiting.
type enter key (OK) at JavaScript confirm dialog window.
push "Yes" button at JavaScript confirm dialog window.
type escape key (cancel) at JavaScript confirm dialog window.
Enter username, password at Basic Auth dialog window.
options : hash title : dialog window title. user : username. password : username. ex) $ie->goto('https://pause.perl.org/pause/authenquery', 1); ## no wait $ie->logon( title => "pause.perl.org へ接続", user => "myname", password => "mypassword", );
maximize specified title window.
arg[0] : window Title name (optional)
delete IE cookies.
delete IE caches.
show PopUp dialog window.
title : dialog window title. message: messages. mode : mode of buttons: . 0 = OK . 1 = OK and Cancel . 2 = Abort, Retry, and Ignore . 3 = Yes, No and Cancel . 4 = Yes and No . 5 = Retry and Cancel return values: . 0 Error . 1 OK . 2 Cancel . 3 Abort . 4 Retry . 5 Ignore . 6 Yes . 7 No
see more detail: http://search.cpan.org/perldoc?Win32
return string - trim \s+
private method for testing. use only with t/*.t test.
Win32 Win32::OLE Win32::IEAutomation
Kazuhito Shimizu, <kazuhito.shimizu@gmail.com>
same as Win32::IEAutomation..
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'へ接続",'. Assuming UTF-8
To install Win32::Watir, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::Watir
CPAN shell
perl -MCPAN -e shell install Win32::Watir
For more information on module installation, please visit the detailed CPAN module installation guide.