37,741
社区成员
发帖
与我相关
我的任务
分享 use Win32::IEAutomation;
# Creating new instance of Internet Explorer
my $ie = Win32::IEAutomation->new( visible => 1, maximize => 1);
# Site navigation
$ie->gotoURL('http://www.google.com');
# Finding hyperlinks and clicking them
# Using 'linktext:' option (text of the link shown on web page)
$ie->getLink('linktext:', "About Google")->Click;
# Or using 'linktext:' option with pattern matching
$ie->getLink('linktext:', qr/About Google/)->Click;
# Or using 'id:' option ( <a id=1a class=q href=......>)
$ie->getLink('id:', "1a")->Click;
# Finding checkbox and selecting it
# Using 'name:' option ( <input type = "checkbox" name = "checkme" value = "1"> )
$ie->getCheckbox('name:', "checkme")->Select;
# Or using 'aftertext:' option (for checkbox after some text on the web page)
$ie->getCheckbox('aftertext:', "some text here")->Select;
# Finding text field and entering data into it
# Using 'name:' option ( <input type="text" name="username" .......> )
$ie->getTextBox('name:', "username")->SetValue($user);
# Finding button and clicking it
# using 'caption:' option
$ie->getButton('caption:', "Google Search")->Click;
# Accessing controls under frame
$ie->getFrame("name:", "content")->getLink("linktext:", "All Documents")->Click;
# Nested frames
$ie->getFrame("name:", "first_frame")->getFrame("name:", "nested_frame");
# Catching the popup as new window and accessing controls in it
my $popup = $ie->getPopupWindow("title of popup window");
$popup->getButton('value:', "button_value")->Click;