Problem with IE automation in Perl

  • Thread starter shankar_perl_rookie
  • Start date
S

shankar_perl_rookie

Hello All,

I am looking to automate IE search using Perl. The site I am trying to
access has a security certificate and I am trying to send an enter
command to just click 'OK' on the security dialog box that opens. I
tried win32::IEAutomation in combination with win32::winclicker which
probably has the exact method to do this but somehow in my case, it is
not able to recognize the dialog box i feel. Here is the code I have.
Please take a look and let me know where I am possibly going wrong:

use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
use Win32::IEAutomation;
use Win32::IEAutomation::WinClicker; # this will provide methods to
interact with dialog box
#use Win32::GuiTest; # qw(FindWindowLike GetWindowText
SetForegroundWindow SendKeys);

my $title ='Choose a digital certificate';
my $wait= 5;

# Creating new instance of Internet Explorer

my $ie = Win32::IEAutomation->new( visible => 1);

# Site navigation

$ie->gotoURL('https:......');

# managing security dialog boxes

my $clicker = Win32::IEAutomation::WinClicker->new();
$clicker->push_confirm_button_ok($title,$wait);
$ie->WaitforDone; # we will wait here for complete loading of
navigated site

The push confirm method is as follows :

sub push_confirm_button_ok{

print "hello inside yes loop \n";
my ($self, $title,$wait) = @_;
print "$self \n$title \n$wait \n";
$wait = 5 unless $wait;
$self->{autoit}->WinTitleMatchMode(3);
my $window = $self->{autoit}->WinWait($title, "", $wait);
if ($window){
print "break 4 inside open window loop \n";
$self->{autoit}->WinActivate($title);
$self->{autoit}->Send('{ENTER}');
}else{
print "WARNING: No Security Alert dialog is present. Function
push_security_alert_yes is timed out.\n" if $warn;
}
}


It is never entering the break point 4 which means that $window is not
recognized. What could be the reason ?

Thanks a lot
 
M

Mark

Hello All,

I am looking to automate IE search using Perl. The site I am trying to
access has a security certificate and I am trying to send an enter
command to just click 'OK' on the security dialog box that opens. I
tried win32::IEAutomation in combination with win32::winclicker which
probably has the exact method to do this but somehow in my case, it is
not able to recognize the dialog box i feel. Here is the code I have.
Please take a look and let me know where I am possibly going wrong:

 use strict;
 use Win32::OLE;
 use Win32::OLE::Const 'Microsoft Excel';
  use Win32::IEAutomation;
 use Win32::IEAutomation::WinClicker; # this will provide methods to
interact with dialog box
 #use Win32::GuiTest; # qw(FindWindowLike GetWindowText
SetForegroundWindow SendKeys);

 my $title ='Choose a digital certificate';
 my $wait= 5;

 # Creating new instance of Internet Explorer

my $ie = Win32::IEAutomation->new( visible => 1);

# Site navigation

  $ie->gotoURL('https:......');

# managing security dialog boxes

   my $clicker = Win32::IEAutomation::WinClicker->new();
   $clicker->push_confirm_button_ok($title,$wait);
   $ie->WaitforDone; # we will wait here for complete loading of
navigated site

The push confirm method is as follows :

sub push_confirm_button_ok{

        print "hello inside yes loop \n";
        my ($self, $title,$wait) = @_;
        print "$self \n$title \n$wait \n";
        $wait = 5 unless $wait;
        $self->{autoit}->WinTitleMatchMode(3);
        my $window = $self->{autoit}->WinWait($title, "", $wait);
        if ($window){
                print "break 4 inside open window loop \n";
                $self->{autoit}->WinActivate($title);
                $self->{autoit}->Send('{ENTER}');
        }else{
                print "WARNING: No Security Alert dialog is present. Function
push_security_alert_yes is timed out.\n" if $warn;
        }

}

It is never entering the break point 4 which means that $window is not
recognized. What could be the reason ?

Thanks a lot

I've never used those modules. You might try using Win32::GuiTest to
send ENTER to that dialog:

use Win32::GuiTest qw(SendKeys SetForegroundWindow WaitWindow);

my $whdl = WaitWindow($title,$wait) || die "Window '$title' not found.
\n";
SetForegroundWindow($whdl) || die "could not set foreround window
'$title'";
SendKeys('{ENTER}');
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top