Reputation: 6898
Using Selenium Grid2 and RemoteWebDriver in an MSTest class, I am struggling to get OperaDriver working.
I create the Selenium hub and Opera node by running the following commands in CMD:
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
And this works fine, I can the see the registered node when I view my hub in a browser.
But I get an exception whenever I try to create a new WebDriver
in my C# test class:
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);
Actually I get two different exceptions - the first time after creating the hub and node in Selenium I get this:
Could not find a platform that supports bundled launchers, please set it manually
Build info: version: '2.30.0', revision: 'dc1ef9c', time: '2013-02-19 00:15:27'
System info: os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_15'
Driver info: driver.version: OperaDriver
And everytime after that I get the following error:
Could not initialize class com.opera.core.systems.runner.launcher.OperaLauncherRunner
I am using Selenium-standalone-2.30.0
.
I was using Opera version 12.14 but downgraded to 11.62 after I saw a list of compatible versions on the OperaDriver wiki page but the errors remain the same.
I have tried initialising the RemoteWebDriver with and without the capabilities above and get the same result every time.
Does anyone know what the problem is here and how to get a RemoteWebDriver working with Opera in this way?
Edit: Could it be that the platform for Opera version 12.14
reads as 'WINDOWS 8'
, and version 11.62
reads as "WIN32"
when I open the Opera
browser and view Help => About
? As I am specifying the platform as WINDOWS
in the node and RemoteWebDriver
. If I try to specify WINDOWS 8 as the platform for the RemoteWebDriver an new exception is thrown where it can't find matching enum:
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: No enum constant org.openqa.selenium.Platform.WINDOWS 8
Edit2: For some reason CurrentPlatform
is returning Vista
for me, even though I am running Windows8
.
Platform platform = Platform.CurrentPlatform;
And I also noticed that the OperaDriver
source code checks for 'VISTA' in uppercase whereas the Platform in C# reads as 'Vista'.
Could this be causing the problem?
Upvotes: 1
Views: 1970
Reputation: 31
I've been suffering from this problem as well and thanks to the hint from eviltester I was able to solve the issue by using the following command line to start the selenium server:
java -Dos.name=windows -jar selenium-server-standalone-2.32.0.jar
The use of -Dos.name=windows
is the equivalent of System.setProperty("os.name", "windows")
and will allow your C# selenium code to work for the Opera browser.
Upvotes: 3
Reputation: 11
I saw this when running in Java. In debug mode it looked like a possible omission in OperaLauncherRunner.java launcherNameForOS does not cater for the WIN8 enum returned by Platform.getCurrent().
In Java I fudged it by setting the system property "os.name" to "windows" before creating a new OperaDriver. This forced the Platform.getCurrent to return XP which the opera launcher was happy with.
So in java I just used this hack:
System.setProperty("os.name","windows");
driver = new OperaDriver();
Upvotes: 1