Re: SELENIUM clickandWait or Timeout or else
Posted: Wed Jun 22, 2016 8:20 am
Hi,
The below code successfully logs into an office 365 portal and then sign outs again using Nagios/selenium. You have to put in otherwise the script will fail
The below code successfully logs into an office 365 portal and then sign outs again using Nagios/selenium. You have to put in
Code: Select all
elsif ( ! $sel->pause("5000") ) {}Code: Select all
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;
use TimePerf2;
my $time= TimePerf2->new(60,90,120);
my $sel = Test::WWW::Selenium->new( host => "seleniumserver",
port => 4444,
browser => "*iexplore",
browser_url => "https://login.microsoftonline.com/" );
$time->startTime("ALL");
$sel->set_timeout_ok("120000");
if ( ! $sel->open_ok("/login.srf?wa=wsignin1.0&rpsnv=4&ct=1466600682&rver=6.7.6640.0&wp=MCMBI&wreply=https%3a%2f%2fportal.office.com%2flanding.aspx%3ftarget%3d%252fdefault.aspx&lc=1033&id=501392&msafed=0&client-request-id=71451f75-cfce-44f2-a2df-379b53ddc6c4") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->set_speed("1500") ) { }
elsif ( ! $sel->pause("5000") ) {}
elsif ( ! $sel->type_ok("id=cred_userid_inputtext", "[email protected]") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->pause("5000") ) {}
elsif ( ! $sel->type_ok("id=passwordInput", "passwordforaccount") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->click_ok("id=submitButton") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->wait_for_page_to_load_ok("120000") ) {}
elsif ( ! $sel->click_ok("css=div.tiles-section.section") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->click_ok("xpath=(//button[\@type='button'])[10]") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->click_ok("//a[\@id='O365_SubLink_ShellSignout']/div/span[2]") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->wait_for_page_to_load_ok("120000") ) {}
elsif ( !$time->endTime("ALL") ) { }
else { $time->getTimes(); }
$sel->stop();