Selenium Grid:“找不到此机器的非环回 ip4 地址”和“发生了非法反射访问操作”
Posted
技术标签:
【中文标题】Selenium Grid:“找不到此机器的非环回 ip4 地址”和“发生了非法反射访问操作”【英文标题】:Selenium Grid: "Could not find a non-loopback ip4 address for this machine" and "An illegal reflective access operation has occurred" 【发布时间】:2018-11-03 16:01:39 【问题描述】:我正在尝试在 Windows10 中设置带有集线器的 Selenium Grid,在 Ubuntu 中设置节点。我已经在 virtualbox 中安装了 ubuntu(在我的主机 win10 中运行)。当我尝试注册节点时,出现“找不到此机器的非环回 ip4 地址”的错误。我对这个问题一无所知。请帮忙解决。
我在论坛中找到了类似的问题,但没有明确的解决方案。
当我连接到 LAN 时,收到以下消息。
org.openqa.selenium.WebDriverException: Cound not find a non-loopback ip4 address for this machine
如果我切换到 Wifi,则会出现以下不同的错误。
-VirtualBox:~/Documents$ java -Dwebdriver.gecko.driver="/home/mehamgn/Documents/drivers/geckodriver/" -jar selenium-server-standalone-3.12.0.jar -role node -nodeConfig grid_node.json
18:54:46.792 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.12.0', revision: '7c6e0b3'
18:54:46.860 INFO [GridLauncherV3$3.launch] - Launching a Selenium Grid node on port 5555
2018-05-24 18:54:51.656:INFO::main: Logging initialized @14625ms to org.seleniumhq.jetty9.util.log.StdErrLog
18:54:55.286 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 5555
18:54:55.294 INFO [GridLauncherV3$3.launch] - Selenium Grid node is up and ready to register to the hub
18:54:55.383 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 10000 ms.
18:54:55.388 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://localhost:4444/grid/register
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.openqa.selenium.json.BeanToJsonConverter (file:/home/mehamgn/Documents/selenium-server-standalone-3.12.0.jar) to method sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl.getDeclaredAnnotations()
WARNING: Please consider reporting this to the maintainers of org.openqa.selenium.json.BeanToJsonConverter
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
18:55:00.088 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: Error sending the registration request: Failed to connect to localhost/127.0.0.1:4444
18:55:10.159 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: Failed to connect to localhost/127.0.0.1:4444
18:55:20.171 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: Failed to connect to localhost/127.0.0.1:4444
18:55:30.181 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: Failed to connect to localhost/127.0.0.1:4444
18:55:40.185 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: Failed to connect to localhost/127.0.0.1:4444
18:55:50.198 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: Failed to connect to localhost/127.0.0.1:4444
nodeConfig JSON 文件
"capabilities":
[
"browserName":"firefox",
"version":"60.0.1",
"maxInstances":1
,
"browserName":"chrome",
"version":"66.0.3359.181",
"maxInstances":1
],
"port":5555,
"hubHost":"192.168.2.8",
"hubPort":4444,
"registerCycle":10000,
"register":true,
"timeout":0,
"maxSessions":2
【问题讨论】:
Don't do this @DebanjanB 已更新为实际文本。很抱歉给您带来不便。 【参考方案1】:这第一条错误信息...
org.openqa.selenium.WebDriverException: Cound not find a non-loopback ip4 address for this machine
...表示由于 /etc/hosts (Ubuntu) 文件或 \WINDOWS\system32\drivers\etc 中可能发生的变化,在读取 ip4 地址时出现了一些问题\hosts (Windows) 文件。
你可以在Selenium hub fails loading giving an error could not find non loopback ip address
找到类似的讨论
第二条错误信息...
18:54:55.388 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://localhost:4444/grid/register
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.openqa.selenium.json.BeanToJsonConverter (file:/home/mehamgn/Documents/selenium-server-standalone-3.12.0.jar) to method sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl.getDeclaredAnnotations()
WARNING: Please consider reporting this to the maintainers of org.openqa.selenium.json.BeanToJsonConverter
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
18:55:00.088 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: Error sending the registration request: Failed to connect to localhost/127.0.0.1:4444
18:55:10.159 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: Failed to connect to localhost/127.0.0.1:4444
...暗示 Selenium Grid Node 没有成功注册到 Selenium Grid Hub
然而,启动 Selenium Grid Node 的命令看起来很容易出错,应该如下所示:
java -Dwebdriver.gecko.driver=/home/mehamgn/Documents/drivers/geckodriver -jar selenium-server-standalone-3.12.0.jar -role node -nodeConfig grid_node.json
注意:
-Dwebdriver.gecko.driver
的值必须以二进制名称结尾,例如geckodriver(省略结尾的/
)
确保传递准确的 nodeConfig.json 文件(根据您使用的代码grid_node.json
)
【讨论】:
1) 如何确保正确放置/etc/hosts
文件。我已经浏览了您建议的页面,但没有帮助。 2)我按照你的 cmets 尝试过,但仍然面临问题 mehamgn@mehamgn-VirtualBox:~/Documents$ java -Dwebdriver.gecko.driver=/home/mehamgn/Documents/drivers/geckodriver -jar selenium-server-standalone-3.12.0.jar -role node -nodeConfig grid_node.json
21:08:35.088 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: Error sending the registration request: Failed to connect to localhost/127.0.0.1:4444
我尝试使用 selenium-server-standalone-3.11.0.jar 版本而不是 3.12.0 ,它可以工作。但它看起来不像是版本问题。
问题是间歇性的。当我今天连接时,发生同样的错误。不知道出了什么问题。
这个问题主要出现在我使用nodeConfig
配置功能时。如果我在命令行中提到所有功能,一切正常。需要查看json文件。
nodeConfig
在独立 3.9.1 版本中工作。找到一个有效的配置似乎很神奇。以上是关于Selenium Grid:“找不到此机器的非环回 ip4 地址”和“发生了非法反射访问操作”的主要内容,如果未能解决你的问题,请参考以下文章
测试人员如何搭建Selenium-Grid2环境(参考Java)