在 MSTest 类中使用 Selenium Grid2 和 RemoteWebDriver,我正在努力让 OperaDriver 正常工作。
我通过在 CMD 中运行以下命令来创建 Selenium hub 和 Opera 节点:
start java -jar selenium-server-standalone-2.30.0.jar -role hub
start java -jar selenium-server-standalone-2.30.0.jar -role node -port 7001 -browser "browserName=opera,version=11.62,maxInstances=5,platform=WINDOWS" -hub http://localhost:4444/grid/register
这很好用,当我在浏览器中查看我的集线器时,我可以看到注册的节点。
但是每当我尝试WebDriver
在我的 C# 测试类中创建一个新类时,我都会遇到异常:
DesiredCapabilities operaCapabilities = DesiredCapabilities.Opera();
operaCapabilities.SetCapability(CapabilityType.BrowserName, "opera");
operaCapabilities.SetCapability(CapabilityType.Platform, "WINDOWS");
operaCapabilities.SetCapability(CapabilityType.Version, "11.62");
operaCapabilities.SetCapability("opera.binary", "C:\\Program Files\\Opera\\opera.exe");
operaCapabilities.SetCapability("opera.port", 7001);
RemoteWebDriver operaDriver = new RemoteWebDriver(operaCapabilities);
实际上我得到了两个不同的例外——第一次在 Selenium 中创建集线器和节点后,我得到了这个:
找不到支持捆绑启动器的平台,请手动设置
构建信息:版本:'2.30.0',修订:'dc1ef9c',时间:'2013-02-19 00:15:27'
系统信息:os.name:'Windows 8',os.arch:'x86',os.version:'6.2',java.version:'1.7.0_15'
驱动程序信息:driver.version:OperaDriver
之后每次我都会收到以下错误:
无法初始化类 com.opera.core.systems.runner.launcher.OperaLauncherRunner
我正在使用Selenium-standalone-2.30.0
.
我使用的是 Opera 版本 12.14,但在看到OperaDriver wiki 页面上的兼容版本列表后降级到 11.62,但错误仍然相同。
我尝试使用或不使用上述功能初始化 RemoteWebDriver,并且每次都得到相同的结果。
有谁知道这里的问题是什么以及如何让 RemoteWebDriver 以这种方式与 Opera 一起工作?
编辑:当我打开浏览器并查看时,可能是平台Opera version 12.14
读取为'WINDOWS 8'
,版本11.62
读取为?正如我在节点和. 如果我尝试将 WINDOWS 8 指定为 RemoteWebDriver 的平台,则会在找不到匹配枚举的地方引发新异常:"WIN32"
Opera
Help => About
WINDOWS
RemoteWebDriver
org.openqa.selenium.WebDriverException:java.lang.IllegalArgumentException:没有枚举常量 org.openqa.selenium.Platform.WINDOWS 8
Edit2:出于某种原因CurrentPlatform
正在为我返回Vista
,即使我正在跑步Windows8
。
Platform platform = Platform.CurrentPlatform;
而且我还注意到OperaDriver
源代码检查大写的“VISTA”,而 C# 中的 Platform 读取为“Vista”。
这会导致问题吗?