問題描述
我正在嘗試從集線器到節(jié)點(diǎn)運(yùn)行一個簡單的代碼,集線器和節(jié)點(diǎn)連接成功.
I'am trying to run a simple code from hub to node, hub and node connections are successful.
執(zhí)行程序時(shí)出現(xiàn)異常
org.openqa.selenium.SessionNotCreatedException
我提到的Chrome驅(qū)動路徑是可以從節(jié)點(diǎn)機(jī)器訪問的共享路徑.
Chrome driver path which I have mentioned is a share path that can be accessible from the node machine.
- Chrome 版本:58.0.3029.110
- Chrome 驅(qū)動程序版本:2.9
Hub 和 Node 都是遠(yuǎn)程機(jī)器.
Both Hub and Node are remote machines.
下面是使用的代碼:
public static void main(String[] args) throws MalformedURLException {
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "Q:\xxxxx\chromedriver.exe");
DesiredCapabilities dc = new DesiredCapabilities();
dc.setBrowserName("chrome");
dc.setPlatform(Platform.VISTA);
driver = new RemoteWebDriver(new URL("http://10.xx.xxx.xx:5566/wd/hub"), dc); //node url
driver.get("https://www.google.com");
}
以下是控制臺消息:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, platform=VISTA}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'A5DAFC-W7A-0012', ip: '10.xx.xxx.xx', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at testcases.Grid.main(Grid.java:23)
推薦答案
這是您問題的答案:
正如您使用以下命令啟動 Selenium Grid Hub:
As you have used the following command to start the Selenium Grid Hub:
java -jar selenium-server-standalone-3.4.0.jar -role hub -port 4123
要通過 chromedriver.exe
和 Google Chrome
瀏覽器執(zhí)行您的代碼塊,您可以考慮在端口 上啟動 Selenium Grid Node>5566 通過這個命令:
To execute your code block through chromedriver.exe
and Google Chrome
Browser you can consider to start the Selenium Grid Node on port 5566 through this command:
java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-3.4.0.jar -role node -hub http://localhost:4123/grid/register -port 5566
通過 <IP_of_GridHub>:4123/grid/console
訪問 Selenium Grid Hub 控制臺以查看正在注冊的節(jié)點(diǎn).
Access the Selenium Grid Hub Console through <IP_of_GridHub>:4123/grid/console
to see the Node being registered.
如果這能回答您的問題,請告訴我.
Let me know if this Answers your Question.
這篇關(guān)于RemoteWebDriver 拋出“org.openqa.selenium.SessionNotCreatedException:無法創(chuàng)建新的遠(yuǎn)程會話"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!