【问题标题】:Selenium Server and Chromedriver doesn't work on LinuxSelenium 服务器和 Chromedriver 在 Linux 上不起作用
【发布时间】:2024-01-13 18:03:01
【问题描述】:

我的本​​地机器 (MAC) 上有一个 Selenium 独立服务器,每次运行测试 (WebdriverIO) 时它都能正常工作。

09:27:06.951 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome",
  "goog:chromeOptions": {
    "args": [
      "--headless",
      "--disable-gpu",
      "--window-size=1024,768",
      "--no-sandbox"
    ]
  }
}
09:27:06.962 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.42.591059 (a3d9684d10d61aa0c45f6723b327283be1ebaad8) on port 42652
Only local connections are allowed.
09:27:08.168 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
09:27:08.314 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 3a6c1206b6cd99a762007069868cad2f (org.openqa.selenium.chrome.ChromeDriverService)
09:27:19.053 INFO [ActiveSessions$1.onStop] - Removing session 3a6c1206b6cd99a762007069868cad2f (org.openqa.selenium.chrome.ChromeDriverService)

现在,我正在尝试将 selenium 服务器移动到 Linux 机器上。我配置并安装了所有必要的软件包。然而,考试只是挂了。

来自 Linux 机器的 Selenium 日志

[dnguyen@test tmp]$ java -jar selenium-server-standalone-3.141.59.jar
09:24:02.305 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
09:24:02.373 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-05-03 09:24:02.413:INFO::main: Logging initialized @289ms to org.seleniumhq.jetty9.util.log.StdErrLog
09:24:02.604 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
09:24:02.697 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
09:24:16.387 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome",
  "goog:chromeOptions": {
    "args": [
      "--headless",
      "--disable-gpu",
      "--window-size=1024,768",
      "--no-sandbox"
    ]
  }
}
09:24:16.388 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 72.0.3626.7 (efcef9a3ecda02b2132af215116a03852d08b9cb) on port 29488
Only local connections are allowed.
[1556889856.409][SEVERE]: CreatePlatformSocket() returned an error, errno=0: Address family not supported by protocol (97)
[1556889856.714][SEVERE]: CreatePlatformSocket() returned an error, errno=0: Address family not supported by protocol (97)
09:24:16.791 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
09:24:17.078 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 86ea9b4bd11c3d2d8a994e893440087e (org.openqa.selenium.chrome.ChromeDriverService)

来自 WebdriverIO 的日志

Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/path-to-test.js)

当我在本地机器上运行时,它没有那个错误。不确定 MAC 和 Linux 上的 Selenium Server 有什么不同。

更新:Linux服务器的443端口未打开,无法访问站点。就是这样。

【问题讨论】:

    标签: selenium selenium-webdriver automated-tests selenium-chromedriver webdriver-io


    【解决方案1】:

    Linux 服务器上的 443 端口未打开,因此无法访问该站点。就是这样。

    如果遇到同样情况,可以尝试使用WGET先到达网站。

    【讨论】:

      最近更新 更多