我正在使用 jenkins 在远程 ubuntu 机器上运行测试。我可以通过腻子.exe访问这台机器。我想看到在特定端口上启动的实际浏览器。
我正在使用java1.7 + maven3 + testng6.5。硒罐 - 2.34.0、2.35.0。Firefox 可以通过授予 777 权限为所有用户执行。
我试过了:
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setCapability("platform", Platform.LINUX);
capability.setCapability("binary", "usr/bin/firefox");
try {
driver= new RemoteWebDriver(
new URL("http://staging.mywebsite.com:8083/wd/hub"),
capability.firefox());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.get(productionurl);
错误:
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
只需读取跟踪:您尝试连接的端口似乎在暂存计算机上被阻止。配置防火墙,以便端口 4444 或 8082 允许 tcp 连接。
我的答案分步进行:
1. 在本地计算机上
创建集线器和节点 2. 通过键入http://localhost:4444/grid/console
打开控制台
3.检查创建集线器的IP地址(实际上是您的IP地址)
4. 通过 jenkins 运行远程代码:
try {
driver= new RemoteWebDriver(
new URL("http://ipadress_in_step_3:your_port/wd/hub"),
capability.firefox());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
PS:只要您的"集线器n节点"正在运行,这些步骤就会起作用,该节点在步骤1中启动。