我一直在拼命尝试让以下 perl/Selenium 脚本在我的 GNU Linux 服务器上运行。我不知道为什么我设置为从“登录”页面开始的脚本进入“登录”页面,然后进入“登录错误”页面(参见 PERL 输出)。我相信这是我得到后续错误的原因 - 虽然,我无法弄清楚为什么会发生重定向 - 我验证了脚本中的凭据
任何帮助将不胜感激!
我的 PERL 脚本 -
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 => "*firefox",
browser_url => "http://monitoring.cogenra.com/login/" );
$sel->open_ok("http://monitoring.cogenra.com/login");
$sel->wait_for_page_to_load_ok("90000");
$sel->set_speed(30000);
print "\n". $sel->get_location() ;
$sel->title_is("");
$sel->type_ok("id=ContentPlaceHolder1_txtUname", "CorrectUser");
$sel->type_ok("id=ContentPlaceHolder1_txtPwd", "CorrectPswd");
$sel->click_ok("id=ContentPlaceHolder1_btn_Login");
$sel->wait_for_page_to_load_ok("90000");
print "\n". $sel->get_location() ;
$sel->wait_for_element_present("css=#gn_output > a > span", 90000);
print "\n". $sel->get_location() ;
$sel->title_is("Cogenra Monitoring");
print "\n". $sel->get_location() ;
$sel->click_ok("css=#gn_output > a > span");
$sel->wait_for_page_to_load_ok("60000");
$sel->title_is("Cogenra Monitoring");
$sel->click_ok("css=div.ob_iDdlTR");
$sel->click_ok("css=b");
$sel->type_ok("id=ContentPlaceHolder1_txt_fromdate", "9/21/2013");
$sel->type_ok("id=ContentPlaceHolder1_txt_todate", "9/27/2013");
PERL 输出 -
ok 1 - open, http://monitoring.cogenra.com/login
ok 2 - wait_for_page_to_load, 90000
http://monitoring.cogenra.com/loginok 3 - get_title, ''
ok 4 - type, id=ContentPlaceHolder1_txtUname, CorrectUser
ok 5 - type, id=ContentPlaceHolder1_txtPwd, CorrectPswd
ok 6 - click, id=ContentPlaceHolder1_btn_Login
ok 7 - wait_for_page_to_load, 90000
http://monitoring.cogenra.com/loginError requesting http://localhost:4444/selenium-server/driver/:
Timed out after 30000ms
1..7
# Looks like your test exited with 255 just after 7.
这是硒服务器输出
01:26:54.418 INFO - Command request: getNewBrowserSession[*firefox, http://monitoring.cogenra.com/login/] on session null
01:26:54.418 INFO - creating new remote session
01:26:54.418 INFO - Allocated session 86f865ad4b864b40ba7cdac1d4da6972 for http://monitoring.cogenra.com/login/, launching...
jar:file:/home/oracle/downloads/selenium-server-standalone-2.35.0.jar!/customProfileDirCUSTFFCHROME
01:26:54.436 INFO - Preparing Firefox profile...
01:26:55.338 INFO - Launching Firefox...
01:26:57.358 INFO - Got result: OK,86f865ad4b864b40ba7cdac1d4da6972 on session 86f865ad4b864b40ba7cdac1d4da6972
01:26:57.361 INFO - Command request: testComplete[, ] on session 86f865ad4b864b40ba7cdac1d4da6972
01:26:57.361 INFO - Killing Firefox...
01:26:57.417 INFO - Got result: OK on session 86f865ad4b864b40ba7cdac1d4da6972
01:27:27.794 INFO - Command request: getNewBrowserSession[*firefox, http://monitoring.cogenra.com/login/] on session null
01:27:27.794 INFO - creating new remote session
01:27:27.795 INFO - Allocated session 2e43642945e64039a30b761f35914083 for http://monitoring.cogenra.com/login/, launching...
jar:file:/home/oracle/downloads/selenium-server-standalone-2.35.0.jar!/customProfileDirCUSTFFCHROME
01:27:27.812 INFO - Preparing Firefox profile...
01:27:28.714 INFO - Launching Firefox...
01:27:30.863 INFO - Got result: OK,2e43642945e64039a30b761f35914083 on session 2e43642945e64039a30b761f35914083
01:27:30.867 INFO - Command request: open[http://monitoring.cogenra.com/login, ] on session 2e43642945e64039a30b761f35914083
01:27:30.867 WARN - you appear to be changing domains from http://monitoring.cogenra.com/login/ to http://monitoring.cogenra.com/login
this may lead to a 'Permission denied' from the browser (unless it is running as *iehta or *chrome,
or alternatively the selenium server is running in proxy injection mode)
01:27:32.609 INFO - Got result: OK on session 2e43642945e64039a30b761f35914083
01:27:32.612 INFO - Command request: waitForPageToLoad[90000, ] on session 2e43642945e64039a30b761f35914083
01:27:32.616 INFO - Got result: OK on session 2e43642945e64039a30b761f35914083
01:27:32.619 INFO - Command request: setSpeed[30000, ] on session 2e43642945e64039a30b761f35914083
01:27:32.619 INFO - Got result: OK on session 2e43642945e64039a30b761f35914083
01:27:32.621 INFO - Command request: getLocation[, ] on session 2e43642945e64039a30b761f35914083
01:28:02.628 INFO - Got result: OK,http://monitoring.cogenra.com/login on session 2e43642945e64039a30b761f35914083
01:28:02.631 INFO - Command request: getTitle[, ] on session 2e43642945e64039a30b761f35914083
01:28:32.637 INFO - Got result: OK, on session 2e43642945e64039a30b761f35914083
01:28:32.641 INFO - Command request: type[id=ContentPlaceHolder1_txtUname, CorrectUser] on session 2e43642945e64039a30b761f35914083
01:29:02.649 INFO - Got result: OK on session 2e43642945e64039a30b761f35914083
01:29:02.653 INFO - Command request: type[id=ContentPlaceHolder1_txtPwd, CorrectPswd] on session 2e43642945e64039a30b761f35914083
01:29:32.658 INFO - Got result: OK on session 2e43642945e64039a30b761f35914083
01:29:32.661 INFO - Command request: click[id=ContentPlaceHolder1_btn_Login, ] on session 2e43642945e64039a30b761f35914083
01:30:02.714 INFO - Got result: OK on session 2e43642945e64039a30b761f35914083
01:30:02.717 INFO - Command request: waitForPageToLoad[90000, ] on session 2e43642945e64039a30b761f35914083
01:30:32.724 INFO - Got result: OK on session 2e43642945e64039a30b761f35914083
01:30:32.727 INFO - Command request: getLocation[, ] on session 2e43642945e64039a30b761f35914083
01:31:02.732 INFO - Got result: OK,http://monitoring.cogenra.com/login on session 2e43642945e64039a30b761f35914083
01:31:02.736 INFO - Command request: waitForElementPresent[css=#gn_output > a > span, 90000] on session 2e43642945e64039a30b761f35914083
01:32:02.744 INFO - Got result: Timed out after 30000ms on session 2e43642945e64039a30b761f35914083
01:32:02.748 INFO - Command request: testComplete[, ] on session 2e43642945e64039a30b761f35914083
01:32:02.748 INFO - Killing Firefox...
01:32:02.805 INFO - Got result: OK on session 2e43642945e64039a30b761f35914083