Problem with IE automation in Perl

Discussion in 'Perl Misc' started by shankar_perl_rookie, Jul 1, 2010.

  1. 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
     
    shankar_perl_rookie, Jul 1, 2010
    #1
    1. Advertising

  2. shankar_perl_rookie

    Mark Guest

    On Jul 1, 8:48 am, shankar_perl_rookie <> wrote:
    > 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}');
     
    Mark, Jul 1, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. apondu
    Replies:
    0
    Views:
    630
    apondu
    Jul 19, 2007
  2. phil court
    Replies:
    1
    Views:
    155
    Brian Helterline
    Sep 9, 2004
  3. matt
    Replies:
    5
    Views:
    156
  4. Dave
    Replies:
    1
    Views:
    156
  5. Replies:
    3
    Views:
    213
    Matt Garrish
    Sep 11, 2006
Loading...

Share This Page