在一个Grid2类中使用Selenium Grid2和RemoteWebDriver,我很难让OperaDriver工作。
我通过在CMD中运行以下命令创建Selenium和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-1900: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。
我使用的是OperaVersion12.14,但在OperaDriver维基页面上看到兼容版本列表之后,我将其降级为11.62,但是错误仍然是一样的。
我尝试过使用和不具备上述功能的情况初始化RemoteWebDriver,每次都得到相同的结果。
有谁知道这里的问题是什么,以及如何让RemoteWebDriver以这种方式与Opera一起工作?
编辑:当我打开Opera浏览器并查看Help => About时,Opera version 12.14的平台会以'WINDOWS 8'的形式读取,而版本的11.62会以"WIN32"的形式读取吗?因为我在节点和RemoteWebDriver中将平台指定为RemoteWebDriver。如果我试图将WINDOWS 8指定为RemoteWebDriver的平台,就会抛出一个新的异常,在那里它找不到匹配的枚举:
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException:无枚举常数org.openqa.selenium.Platform.WINDOWS 8
Edit2:由于某种原因,CurrentPlatform正在为我返回Vista,尽管我正在运行Windows8。
Platform platform = Platform.CurrentPlatform;我还注意到,源代码以大写字母检查“Vista”,而C#中的平台则为“Vista”。
这可能是问题的根源吗?
发布于 2013-04-22 20:44:41
我也遇到了这个问题,多亏了eviltester的提示,我能够通过使用下面的命令行启动selenium服务器来解决这个问题:
java -Dos.name=windows -jar selenium-server-standalone-2.32.0.jar-Dos.name=windows的使用相当于System.setProperty("os.name", "windows"),将允许您的C# selenium代码在Opera中工作。
发布于 2013-04-17 14:22:07
我在Java中运行时看到了这种情况。在调试模式下,OperaLauncherRunner.java launcherNameForOS中的可能遗漏不适合Platform.getCurrent()返回的WIN8枚举。
在Java中,我在创建新的os.name之前将系统属性“OperaDriver”设置为“OperaDriver”。这迫使Platform.getCurrent返回XP,而opera对此很满意。
所以在java中,我使用了这个黑客:
System.setProperty("os.name","windows");
driver = new OperaDriver();https://stackoverflow.com/questions/15111353
复制相似问题