Cannot access selenium server on localhost from Perl using LWP::UserAgent on Windows 10, Strawberry Perl

南楼画角 提交于 2020-07-16 04:28:08

问题


On Windows 10, I installed geckodriver.exe from https://github.com/mozilla/geckodriver/releases and Selenium Server from https://www.selenium.dev/downloads/

I started the server successfully from the command prompt:

> java  "-Dwebdriver.gecko.driver=geckodriver/geckodriver.exe" -jar selenium-server/selenium-server-standalone-3.141.59.jar -host localhost -port 4444
20:00:48.591 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
20:00:53.896 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2020-07-06 20:00:54.601:INFO::main: Logging initialized @12170ms to org.seleniumhq.jetty9.util.log.StdErrLog
20:01:05.928 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
20:01:23.567 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444

I can test that the server is working by visiting the URL http://localhost:4444/wd/hub/status from Chrome web browser. The output is:

{
  "status": 0,
  "value": {
    "ready": true,
    "message": "Server is running",
    "build": {
      "revision": "e82be7d358",
      "time": "2018-11-14T08:25:53",
      "version": "3.141.59"
    },
    "os": {
      "arch": "amd64",
      "name": "Windows 10",
      "version": "10.0"
    },
    "java": {
      "version": "14.0.1"
    }
  }
}

However, if I try to access the server from Perl using LWP::UserAgent:

use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
my $result=$ua->get("http://localhost:4444/wd/hub/status/");
print $result->status_line.".\n";

the output is:

500 Can't connect to localhost:4444 (Bad address).

来源:https://stackoverflow.com/questions/62762851/cannot-access-selenium-server-on-localhost-from-perl-using-lwpuseragent-on-win

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!