SELENIUM clickandWait or Timeout or else
Posted: Tue Jun 21, 2016 1:59 pm
Hello Nagios support forum
I am very new to SELENIUM IDE and ran into question many other did too: waits or timeouts while pages are loading or redirecting.
Is there a wait command (perl) to use while waiting for redirects?
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;
my $sel = Test::WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*chrome",
browser_url => "https://login.microsoftonline.com/" );
$sel->open_ok("/login.srf?wa=wsignin1.0&rpsnv=4&ct=1466534348&rver=6.7.6640.0&wp=MCMBI&wreply=https%3a%2f%2fportal.office.com%2flanding.as
px%3ftarget%3d%252fdefault.aspx&lc=1033&id=501392&msafed=0&client-request-id=64b6eb2d-3b6f-4bcb-8138-08f686ad8ebd");
$sel->type_ok("id=cred_userid_inputtext", "nagximon\@mydomain.com");
!!! ----- at this point redirect happens, opening another page to enter password ----- !!! / SELENIUM proceeds to the next step right away and fails
$sel->type_ok("id=passwordInput", "mypassword");
$sel->click_ok("id=submitButton");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("xpath=(//button[\@type='button'])[10]");
$sel->click_ok("//a[\@id='O365_SubLink_ShellSignout']/div/span[2]");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("id=submitButton");
$sel->wait_for_page_to_load_ok("30000");
I am very new to SELENIUM IDE and ran into question many other did too: waits or timeouts while pages are loading or redirecting.
Is there a wait command (perl) to use while waiting for redirects?
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;
my $sel = Test::WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*chrome",
browser_url => "https://login.microsoftonline.com/" );
$sel->open_ok("/login.srf?wa=wsignin1.0&rpsnv=4&ct=1466534348&rver=6.7.6640.0&wp=MCMBI&wreply=https%3a%2f%2fportal.office.com%2flanding.as
px%3ftarget%3d%252fdefault.aspx&lc=1033&id=501392&msafed=0&client-request-id=64b6eb2d-3b6f-4bcb-8138-08f686ad8ebd");
$sel->type_ok("id=cred_userid_inputtext", "nagximon\@mydomain.com");
!!! ----- at this point redirect happens, opening another page to enter password ----- !!! / SELENIUM proceeds to the next step right away and fails
$sel->type_ok("id=passwordInput", "mypassword");
$sel->click_ok("id=submitButton");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("xpath=(//button[\@type='button'])[10]");
$sel->click_ok("//a[\@id='O365_SubLink_ShellSignout']/div/span[2]");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("id=submitButton");
$sel->wait_for_page_to_load_ok("30000");