RemoteWebDriver 和 Grid - 是否可以获取服务器 IP?
我使用 Selenium 2 和 Grid 中的 RemoteWebDriver 将测试划分到多个虚拟机上。假设我有两台 Linux 机器,在测试中我指定了在 Linux 机器上运行的功能,但我无法确定正在使用这两台机器中的哪一台。 有什么办法可以弄清楚吗?像 driver.getServerIp() 或者其他什么? 原因是,在我的 Selenium 测试代码中,我想在运行测试的 Linux 机器的控制台上启动 bash 脚本。因此我必须知道测试在哪台机器上运行。
谢谢你们!
I am using RemoteWebDriver from Selenium 2 and Grid to divide my tests on several virtual machines. Let's say I have two Linux machines and in a test I specify the capabilities to run on a Linux machine, I can't figure out which of these two machines is being used.
Is there any way, to figure it out? Something like driver.getServerIp() or anything else?
The reason is, in my Selenium test code I want to start a bash script on the console of the linux machine where the test is being run. Therefore I have to know on which machine the test runs.
Thanks guys!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的java技能不是最好的,这段代码需要一些清理,但这对我有用。
proxyID 包含节点的 IP。
My java skills aren't the greatest and this code could use some cleaning up, but this works for me.
proxyID contains the IP of the node.
尽管您可能知道该地址,因为无论如何您都将其传递到 RemoteWebDriver 的构造函数中。
Although presumably you'd know the address since you passed it into the constructor for RemoteWebDriver anyway.
Bobble D 提供的答案仅有效,正如 Nilesh 提到的那样,JSONParser 也存在问题,这里是更新的代码,可以提供帮助
Answer provided by Bobble D is working only that there was problem with JSONParser as mentioned by Nilesh as well, here is updated code which can help