我的问题或问题 = 我无法使用 selenium 远程服务器运行任何浏览器,我该如何解决这个问题?
我的环境:
- 操作系统 Windows 10
- 我在 java 1.8 中使用 eclipse(Version: Neon Release (4.6.0))
- 硒网络驱动程序 3.0.0
- selenium-server-standalone-3.0.1.jar
我在 cmd 中启动 selenium-server-standalone。(“selenium-server-standalone-3.0.1.jar”文件存储在我的 C 盘上的实用程序文件夹中)
C:\Windows\system32> cd\
C:\> cd utilities
C:\Utilities> java -jar selenium-server-standalone-3.0.1.jar
然后 selenium-server-standalone 启动,一切看起来都很好
当我运行测试时
Eclipse 提供了这个错误:
Feb 09, 2017 10:36:35 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Feb 09, 2017 10:36:35 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Feb 09, 2017 10:36:36 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'MWLTSHAUNCR', ip: '192.168.56.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
Driver info: driver.version: RemoteWebDriver
对于我添加的 remoteDriver 部分,我的代码看起来像这样。我已经包含了类和构造函数
public class browser {
private browser (WebDriver driver){
browser.driver = driver;
}
public static void runRemoteDriver(){
try {
WebDriver webDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),DesiredCapabilities.firefox());
new browser (webDriver);
} catch (Exception e) {
e.printStackTrace();
}
}
}