Loading ...
Sorry, an error occurred while loading the content.

Can't Select Buttons that are in a Frame(Perl Code executable)

Expand Messages
  • markmontemuro
    I m trying to automate a Perl program that contains buttons. I m having problems trying to select buttons. Below is a simple program that I m trying to test
    Message 1 of 1 , Oct 25, 2005
    • 0 Attachment
      I'm trying to automate a Perl program that contains buttons. I'm
      having problems trying to select buttons. Below is a simple program
      that I'm trying to test out. I tried to use both the PushButton and
      PushChildButton. The location of the program will always change, so
      mouse location cannot be true. What would I have to do to select
      either the Save or Exit Buttons in the Pane.pl program?

      GUITest.pl (This runs against the pane.pl script)
      #!perl -w
      use Win32::GuiTest qw(:ALL :SW);

      print "Start:\n";
      $fgWindow = WaitWindowLike(0, "^Data\ Entry\$", "^TkTopLevel\$");
      print "Found Window\n";
      SetForegroundWindow($fgWindow);

      $result=PushButton($fgWindow,'Exit', 0);
      print "Result:$result:\n";


      Pane.pl code to automate:
      !/usr/bin/perl
      use warnings;
      use strict;
      use Tk;
      use Tk::Pane;


      my $mw = MainWindow->new;
      $mw->geometry('600x400');
      $mw->title('Data Entry');


      my %info;


      my $frame = $mw->Frame->pack(-side => 'bottom');


      $frame->Button(
      -text => 'Exit',
      -command => sub { Tk::exit },
      )->pack(-side => 'left');


      $frame->Button(
      -text => 'Save',
      -command => sub { }, # do something with %info;
      )->pack(-side => 'bottom');


      my $pane = $mw->Scrolled('Pane',
      -sticky => 'w n e',
      -scrollbars => 'osoe',
      )->pack(-anchor => 'nw', -expand => 1, -fill => 'both');


      for (qw/Name Address City State Zip Phone Occupation
      Company Business_Address Business_Phone/) {
      my $f1 = $pane->Frame->pack( -anchor => 'nw', -expand => 1, -fill
      => 'x');
      $f1->Label(
      -text => "$_:",
      -relief => 'groove',
      -width => 20
      )->pack(-side => 'left', -anchor => 'nw');


      $f1->Entry(
      -textvariable => \$info{$_}
      )->pack(-side => 'left', -anchor => 'nw', -expand => 1, -fill
      => 'x');



      }


      MainLoop;

      __END__
    Your message has been successfully submitted and would be delivered to recipients shortly.