【问题标题】:Perl selenium remote driver cannot create a new instancePerl selenium 远程驱动程序无法创建新实例
【发布时间】:2013-12-19 21:48:18
【问题描述】:

我的 perl 脚本无法连接到在 localhost 端口 4444 中运行的 selenium 独立服务器。在不同的环境中会发生不同的事情。

Windows 7:脚本有时有效,有时无效。

Selenium 服务器端:正常启动。但是当我创建远程驱动程序实例时没有创建新的会话。

C:\Users\ganess4\msant\nsn_testeng\tools\AutoBuildPromotionEmail>java -jar selenium-server-standalone-2.37.0.jar
Dec 3, 2013 12:16:43 PM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
12:16:43.882 INFO - Java: Sun Microsystems Inc. 20.14-b01
12:16:43.882 INFO - OS: Windows 7 6.1 x86
12:16:43.894 INFO - v2.37.0, with Core v2.37.0. Built from revision a7c61cb
12:16:43.953 INFO - Default driver org.openqa.selenium.iphone.IPhoneDriver regis
tration is skipped: registration capabilities Capabilities [{platform=MAC, brows
erName=iPhone, version=}] does not match with current platform: VISTA
12:16:43.973 INFO - Default driver org.openqa.selenium.iphone.IPhoneDriver regis
tration is skipped: registration capabilities Capabilities [{platform=MAC, brows
erName=iPad, version=}] does not match with current platform: VISTA
12:16:44.020 INFO - RemoteWebDriver instances should connect to: http://127.0.0.
1:4444/wd/hub
12:16:44.021 INFO - Version Jetty/5.1.x
12:16:44.022 INFO - Started HttpContext[/selenium-server/driver,/selenium-server
/driver]
12:16:44.023 INFO - Started HttpContext[/selenium-server,/selenium-server]
12:16:44.024 INFO - Started HttpContext[/,/]
12:16:44.074 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@1754ad
2
12:16:44.074 INFO - Started HttpContext[/wd,/wd]
12:16:44.112 INFO - Started SocketListener on 0.0.0.0:4444
12:16:44.112 INFO - Started org.openqa.jetty.jetty.Server@c1b531

代码方面:注意我确实尝试了端口 4444 和其他变体。

my $browser = "firefox";
    my $platform = "WINDOWS";
    eval
    {
        $self->{seldriverarray} = new Selenium::Remote::Driver(browser_name => $browser, platform => $platform);
        $self->{seldriverarray}->debug_on;
        print Dumper $self->{seldriverarray}->status;
    };

抛出以下内容

Use of uninitialized value in string ne at C:/Dwimperl/perl/site/lib/Selenium/Re
mote/RemoteConnection.pm line 30, <FH> line 48.
Use of uninitialized value in string eq at C:/Dwimperl/perl/site/lib/Selenium/Re
mote/RemoteConnection.pm line 35, <FH> line 48.
Selenium server did not return proper status at C:/Dwimperl/perl/site/lib/Seleni
um/Remote/Driver.pm line 232.

当我在另一个环境中运行它时会发生最奇怪的事情 Suse 企业版:

Selenium 服务器端:看到它创建了一个新会话,这意味着代码没有错误。那么,是什么阻止了代码在 Windows 中启动新会话?我无法在linux中运行脚本,因为它正在超时很长一段时间无法启动firefox。

12:32:09.969 INFO - Started org.openqa.jetty.jetty.Server@181edf4
12:32:19.041 INFO - Executing: [new session: {platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, version=}] at URL: /session)
12:32:19.057 INFO - Creating a new session for Capabilities [{platform=WINDOWS, javascriptEnabled=true, acceptSslCerts=true, browserName=firefox, version=}]

【问题讨论】:

  • 如果您查看网格控制台,您将看到集线器具有哪些功能,所以从您在 localhost:4444/grid/console 启动它的主机上看到,我怀疑您可能需要类似 VISTA 的平台
  • 我在 Selenium RemoteConnection.pm 代码中打开了调试选项,我看到它在 LWP http 包中超时。 package LWP::Protocol::http::SocketMethods; sub sysread { my $self = shift; if (my $timeout = ${*$self}{**io_socket_timeout**}) { **die "read timeout" unless $self-&gt;can_read($timeout)**; }

标签: perl selenium selenium-webdriver


【解决方案1】:

更新 Net::HTTPS 和 IO::Socket::SSL 后,问题得到解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 2019-01-14
    • 1970-01-01
    • 2017-07-09
    • 1970-01-01
    • 2017-02-27
    相关资源
    最近更新 更多