SELENIUM errors in GUI, but works with Perl CLI

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

SELENIUM errors in GUI, but works with Perl CLI

Post by dlukinski »

Hello XI Support

We are getting errors (file attached) when using check_selenium in XI GUI, while perl command works in CLI for the same scripts:
--------------------------------------------------------------------------------------------------------------------------------------------------------

[root@fikc-nagxidev01 tmp]# perl msportal-3
ok 1 - set_timeout, 120000
ok 2 - open, /login.srf?wa=wsignin1.0&rpsnv=4&ct=1466534348&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=64b6eb2d-3b6f-4bcb-8138-08f686ad8ebd
ok 3 - type, id=cred_userid_inputtext, [email protected]
ok 4 - type, id=passwordInput, mypassword
ok 5 - click, id=submitButton
ok 6 - wait_for_page_to_load, 120000
ok 7 - click, //a[@id='ShellSites_link']/span
ok 8 - wait_for_page_to_load, 120000
ok 9 - click, xpath=(//button[@type='button'])[12]
ok 10 - click, //a[@id='O365_SubLink_ShellSignout']/div/span[2]
ok 11 - wait_for_page_to_load, 120000
Key: ALL, Value: 1466730047.48348:1
Start Time: 1466730047.48348
End Time: 1466730087.48264
OK: Processes completed after 39.999 of page loading.|0| ALL=39.999s;60;90;0;120 |1..11

[root@fikc-nagxidev01 tmp]# perl msportal-4
ok 1 - set_timeout, 120000
ok 2 - open, /login.srf?wa=wsignin1.0&rpsnv=4&ct=1466534348&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=64b6eb2d-3b6f-4bcb-8138-08f686ad8ebd
ok 3 - type, id=cred_userid_inputtext, [email protected]
ok 4 - type, id=passwordInput, mypassword
ok 5 - click, id=submitButton
ok 6 - wait_for_page_to_load, 120000
ok 7 - click, //a[@id='ShellDocuments_link']/span
ok 8 - wait_for_page_to_load, 120000
ok 9 - click, xpath=(//button[@type='button'])[11]
ok 10 - click, //a[@id='O365_SubLink_ShellSignout']/div/span[2]
ok 11 - wait_for_page_to_load, 120000
Key: ALL, Value: 1466731031.36598:1
Start Time: 1466731031.36598
End Time: 1466731083.44709
OK: Processes completed after 52.081 of page loading.|0| ALL=52.081s;60;90;0;120 |1..11
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
msportal-3 script (XI ERROR: Element xpath=(//button[@type='button'])[11] not found)

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 => "10.96.36.114",.
                                    port => 4444,.
                                    browser => "*firefox",.
                                    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=1466534348&rver=6.7.6640.0&wp=MCMBI&wreply=https%3a%2f%2fportal.office.com%2flanding.aspx%3ftarge
elsif ( ! $sel->set_speed("1500") ) { }

elsif ( !  $sel->type_ok("id=cred_userid_inputtext", "nagximon\@mydomain.com") ) {print "Location: " . $sel->get_location() . "\n";}

elsif ( !  $sel->pause(8000) ) {}
elsif ( !  $sel->type_ok("id=passwordInput", "mypassword") ) {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->pause(8000) ) {}
elsif ( !  $sel->click_ok("//a[\@id='ShellSites_link']/span") ) {print "Location: " . $sel->get_location() . "\n";}

elsif ( !  $sel->wait_for_page_to_load_ok("120000") ) {}.
elsif ( !  $sel->pause(8000) ) {}
elsif ( !  $sel->click_ok("xpath=(//button[\@type='button'])[12]") ) {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();
msportal-4 (XI ERROR: Element xpath=(//button[@type='button'])[12] not found)

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 => "10.96.36.114",
                                    port => 4444,
                                    browser => "*firefox",
                                    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=1466534348&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=64b6eb2d-3b6f-4bcb-8138-08f686ad8ebd") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->set_speed("1500") ) { }

elsif ( !  $sel->type_ok("id=cred_userid_inputtext", "nagximon\@mydomain.com") ) {print "Location: " . $sel->get_location() . "\n";}

elsif ( !  $sel->pause(8000) ) {}
elsif ( !  $sel->type_ok("id=passwordInput", "mypassword") ) {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->pause(8000) ) {}
elsif ( !  $sel->click_ok("//a[\@id='ShellDocuments_link']/span") ) {print "Location: " . $sel->get_location() . "\n";}

elsif ( !  $sel->wait_for_page_to_load_ok("120000") ) {}
elsif ( !  $sel->pause(12000) ) {}
elsif ( !  $sel->click_ok("xpath=(//button[\@type='button'])[11]") ) {print "Location: " . $sel->get_location() . "\n";}

elsif ( !  $sel->pause(8000) ) {}
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();
You do not have the required permissions to view the files attached to this post.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: SELENIUM errors in GUI, but works with Perl CLI

Post by Box293 »

I see your tests at the CLI are run as the user root.

Can you please re-run the tests, but su to the nagios user first:

Code: Select all

su nagios
perl msportal-3
What output does this produce?

Sometimes you need to define environment variables for Nagios to run when the service starts, this is outlined here:

https://support.nagios.com/kb/article.php?id=489

Does this help?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: SELENIUM errors in GUI, but works with Perl CLI

Post by dlukinski »

Box293 wrote:I see your tests at the CLI are run as the user root.

Can you please re-run the tests, but su to the nagios user first:

Code: Select all

su nagios
perl msportal-3
What output does this produce?

Sometimes you need to define environment variables for Nagios to run when the service starts, this is outlined here:

https://support.nagios.com/kb/article.php?id=489

Does this help?
This was something else this time: changed pauses inside Selenium Perl script and it started working in GUI :-\

Are there any hardcoded timelimits in check_selenium we could extend (if check runs for over 30 sec?)
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: SELENIUM errors in GUI, but works with Perl CLI

Post by mcapra »

dlukinski wrote: Are there any hardcoded timelimits in check_selenium we could extend (if check runs for over 30 sec?)
Not for the plugin mentioned in the docs (https://assets.nagios.com/downloads/nag ... k_selenium). All check_selenium really does is call the test case, check the output of that test case, then format the output in a Nagios/PHP friendly way.
Former Nagios employee
https://www.mcapra.com/
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: SELENIUM errors in GUI, but works with Perl CLI

Post by dlukinski »

mcapra wrote:
dlukinski wrote: Are there any hardcoded timelimits in check_selenium we could extend (if check runs for over 30 sec?)
Not for the plugin mentioned in the docs (https://assets.nagios.com/downloads/nag ... k_selenium). All check_selenium really does is call the test case, check the output of that test case, then format the output in a Nagios/PHP friendly way.
Alright, let's get back to it when fails again. Please close the case
Locked