在 Linux 上设置 Selenium 节点

Setting up a Selenium node on Linux

我目前正在尝试在 Linux 虚拟机(无头)上设置一个 Selenium 节点。集线器正在 运行 来自端口 5786 上的 Windows 设备(4444 正在使用中)。

我使用以下代码启动集线器:

java -jar selenium-server-standalone-
2.53.0.jar -role node –hub http://<myIP>:5786/grid/register -port 5558

当我执行它时,returns 出现以下错误消息:

13:42:12.765 INFO - Launching a Selenium Grid node
13:42:13.435 WARN - error getting the parameters from the hub. The node may 
end up with wrong timeouts.Connect to 10.146.48.80:4444 [/10.146.48.80] 
failed: Connection refused
13:42:13.445 INFO - Java: Oracle Corporation 24.60-b09
13:42:13.445 INFO - OS: Linux 3.10.0-514.21.1.el7.x86_64 amd64
13:42:13.450 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b
13:42:13.521 INFO - Driver provider 
org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, 
ensureCleanSession=true, browserName=internet explorer, version=}] does not 
match the current platform LINUX
13:42:13.521 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver 
registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, 
browserName=MicrosoftEdge, version=}] does not match the current platform 
LINUX
13:42:13.521 INFO - Driver class not found: 
com.opera.core.systems.OperaDriver
13:42:13.521 INFO - Driver provider com.opera.core.systems.OperaDriver is not 
registered
13:42:13.522 INFO - Driver provider org.openqa.selenium.safari.SafariDriver 
registration is skipped:
registration capabilities Capabilities [{platform=MAC, browserName=safari, 
version=}] does not match the current platform LINUX
13:42:13.523 INFO - Driver class not found: 
org.openqa.selenium.htmlunit.HtmlUnitDriver
13:42:13.523 INFO - Driver provider 
org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
13:42:13.552 INFO - Version Jetty/5.1.x
13:42:13.553 INFO - Started HttpContext[/selenium-server/driver,/selenium-
server/driver]
 13:42:13.553 INFO - Started HttpContext[/selenium-server,/selenium-server]
13:42:13.553 INFO - Started HttpContext[/,/]
13:44:03.596 INFO - Started 
org.openqa.jetty.jetty.servlet.ServletHandler@188fd321
13:44:03.596 INFO - Started HttpContext[/wd,/wd]
13:44:03.599 INFO - Started SocketListener on 0.0.0.0:5555
13:44:03.599 INFO - Started org.openqa.jetty.jetty.Server@a01330f
13:44:03.599 INFO - Selenium Grid node is up and ready to register to the hub
13:44:03.630 INFO - Starting auto registration thread. Will try to register 
every 5000 ms.
13:44:03.630 INFO - Registering the node to the hub: 
http://10.146.48.80:4444/grid/register
13:44:03.638 INFO - Couldn't register this node: Error sending the 
registration request: Connect to 10.146.48.80:4444 [/10.146.48.80] failed: 
Connection refused

在您分享的命令中,即

java -jar selenium-server-standalone-2.53.0.jar -role node –hub http://<myIP>:5786/grid/register -port 5558

您遇到了复制粘贴问题。参数hub前的-好像不是hyphen字符。

我能够推断出这是一个可能的根本原因,因为 -hub 的值被完全忽略并且正在尝试使用 4444 的默认集线器端口。您共享的堆栈跟踪重复了这个

13:42:13.435 WARN - error getting the parameters from the hub. The node may end up with wrong timeouts.Connect to 10.146.48.80:4444 [/10.146.48.80] failed: Connection refused

如您所见,即使您提供集线器的注册 URL 以包含端口号 5786,它仍然在接收 4444 并抱怨 Connection refused

请尝试输入启动集线器的完整命令,然后重试。那应该有用。