0

我想检查 Selenium Hub 或 Node 是否在特定端口上运行(例如:- 5555)。我已经有了检查特定端口是否空闲的代码。但我不确定如何使用端口找出应用程序。

if (Port is free)
    i=1
else if (Port is used as Selenium Hub)
    i=2
else if (Port is used as Selenium Node)
    i=3
else if (Port is used by apps other than Selenium)
    i=4
else
    i=5

请让我知道这是否可以使用 java 完成。

4

1 回答 1

4

您可以尝试访问节点/服务器的已知 http url,如果它以非错误响应(让我们看到 200 OK),您可以假设它是在那里运行的 selenium,例如做一个 httpclient 到:

http://<host>:<port>/wd/hub/static/resource/hub.html

如果它执行 404,则它不是硒。

于 2013-04-25T22:01:11.343 回答