使用selenium网格运行selenium测试用例时出错?
我的浏览器调用代码如下所示:使用selenium网格运行selenium测试用例时出错?,selenium,selenium-grid,Selenium,Selenium Grid,我的浏览器调用代码如下所示: else if(browserName.equals("chrome")) { System.setProperty("webdriver.chrome.driver", "/home/selenium-drivers/chromedriver"); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabili
else if(browserName.equals("chrome")) {
System.setProperty("webdriver.chrome.driver", "/home/selenium-drivers/chromedriver");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setPlatform(Platform.LINUX);
URL url_hub = new URL("http://my-remote-server-ip:4444/wd/hub");
driver = new RemoteWebDriver(url_hub, capabilities);
driver.manage().window().maximize();
driver.get(url);
}
运行程序时出现以下错误:
无法创建新的远程会话。所需功能=功能[{browserName=chrome,版本=,平台=WINDOWS}],所需功能=功能[{}]
[]
以下是你问题的答案: Windows平台
14:25:50.350 INFO - Selenium Grid hub is up and running
java -Dwebdriver.chrome.driver=C:\Utility\BrowserDrivers\chromedriver.exe -jar C:\Utility\selenium-server-standalone\selenium-server-standalone-3.4.0.jar -role node -hub http://localhost:4444/grid/register
14:33:12.354 INFO - Selenium Grid node is up and ready to register to the hub
14:33:12.409 INFO - Starting auto registration thread. Will try to register every 5000 ms.
14:33:12.409 INFO - Registering the node to the hub: http://localhost:4444/grid/register
14:33:12.756 INFO - The node is registered to the hub and ready to use
localhost:4444
settings:
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setBrowserName("chrome");
cap.setPlatform(Platform.WINDOWS);
URL url = new URL("http://localhost:4444/wd/hub");
WebDriver driver = new RemoteWebDriver(url, cap);
driver.get("http://google.com/");
System.out.println("Title is : "+driver.getTitle());
driver.quit();
Title is : Google
PASSED: test1
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================
让我知道这是否对您有帮助。您是否成功启动了集线器和节点?@Dev是的。我收到了控制台消息“08:40:54.801信息-节点已注册到集线器并准备好使用”。您能告诉我如何启动集线器和节点的命令吗?Thanks@Dev我正在通过Jenkins运行hub,并且我正在为节点“java-jar selenium-server-standalone-3.4.0.jar-role node-hub”使用的命令检查网格控制台,如果您看到节点注册器已经完成了上述所有步骤,但是“org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话。所需功能=功能[{browserName=chrome,版本=,平台=WINDOWS}],所需功能=功能[{}]构建信息:版本:'3.0.1',版本:'1969d75',时间:'2016-10-18 09:49:13-0700'系统信息:主机:'arima-latitude-3460',ip:'127.0.1.1',os.name:'Linux',os.arch:'amd64',os.version:'3.13.0-117-generic',java.version:'1.8.0131'驱动程序信息:Driver.version:RemoteWebDriver“此错误。您的操作系统是Linux,因此必须相应地进行某些更改。1.
chromedriver的路径
(Linux类型绝对路径&不带扩展名).2.将Platform.WINDOWS
更改为Platform.LINUX
3.传递准确的IP和端口,而不是http://localhost:4444/wd/hub
我已经在代码中更改了这一点,现在在本地机器上运行程序时工作正常,但在云上运行代码时仍然会出现相同的错误。让我们来看看。