Hi all,
just my first technical post on this list.
To automate my work i have to get a html page by my company site after a
login in an secure area.
After a long googling job, I decided to use WWW:Selenium to do this.
It seems to be bugged and i would ask to you if there is e clear method
to do this.
Many thanks in advance.
There is my code:
CODE
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More no_plan;
use Test::Exception;
#system ('/usr/bin/selenium-server ');
my $line = 'td colspan=1 class=tdInt3 align=center';
my $users_file = config_user.cfg ;
open ( USERS , $users_file ) or die Unable to open file:
$users_file\n $!\n;
my $string = ;
## Perl trim function to remove whitespace from the start and end of the
string
sub trim($) {
$string = shift;
$string =~ s/.*\(.*?)\.*/$1/ ;
return $string;
}
my $sel = Test::WWW::Selenium-new( host = localhost,
port = ,
browser = *firefox,
browser_url =
http://webmail.sorint.it/; );
$sel-open_ok(http://x;);
$sel-title_is(Sun Java System Access Manager (Login));
$sel-type_ok(IDToken1, x);
$sel-type_ok(IDToken2, x);
$sel-click_ok(Login.Submit);
$sel-wait_for_page_to_load_ok(3);
$sel-title_is();
$sel-open_ok('https://x/http://its-cslpsr-01.sorint.it/nextstage/jsp/index.jsp');
my $i = ;
while ($i = USERS) {
my $field1 = ;
my $field2 = ;
my $field3 = ;
my $line = $i;
($field1,$field2,$field3) = split ';', $line;
print $field1\t.$field2\t.$field3\n;
my $compurl0 =
'https://x/http://its-cslpsr-01.xx.it/nextstage/contratti/resoconto/RiepilogoOre.jsp?matricola='.$field2.'mese_m=maranno_a=2010tipo=';
my $compurl1 =
'https://x/http://its-cslpsr-01.xx.it/nextstage/contratti/resoconto/RiepilogoOreCommercio.jsp?matricola='.$field2.'mese_m=maranno_a=2010tipo=';
if ( $field1 == 0 ) {
print Il campo di controllo è 0 e quindi uso la stringa:\n
$compurl0;
$sel-open_ok($compurl0);
$sel-wait_for_page_to_load_ok(3);
sleep 30;
} else {
print Il campo di controllo è 1 e quindi uso la stringai:\n
$compurl1;
$sel-open_ok($compurl1);
$sel-wait_for_page_to_load_ok(3);
sleep 30;
}
my $outfile = out-$field2.htm;
my $output_page = $sel-get_html_source;
open(OUTFILE, $outfile);
print OUTFILE $output_page;
close(OUTFILE);
open ( FILE , $outfile ) or die Cannot open file: $outfile - $! \n;
open ( LINES , data-$field2.txt ) or die Cannot open file:
data-$field2.txt - $! \n;
open ( PIPPO , original-$field2.txt ) or die Cannot open file
original-$field2.txt: $! \n;
my $counter = 0;
my $row = ;
while ($row = FILE) {
$counter++;
if ($row =~ /$line/) {
$a = trim($row);
open ( LINES , data-$field2.txt ) or die Cannot
open file data-$field2.txt: $! \n;
open ( PIPPO , original-$field2.txt ) or die
Cannot open file original-$field2.txt: $! \n;
print PIPPO $row;
print LINES $a;
close LINES;
close PIPPO;
}
}
close FILE;
close LINES;
}
close USERS;
exit;
--
go ahead... be a heretic!
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/