OS: Windows 2012
Selenium Version:
Webdriver 3.3 .NET bindings
selenium-server-standalone-3.3.1.jar
Browser: Firefox
Browser Version: 47.0.1
Tests can be run using RemoteWebDriver and a grid running 3.3.1
The following exception is generated when creating a RemoteWebDriver instance:
An unhandled exception of type 'System.InvalidOperationException' occurred in WebDriver.dll
Additional information: org.openqa.selenium.remote.service.DriverCommandExecutor cannot be cast to org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor
C# code snippet below....
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;
namespace FFStartUpProblem
{
internal class Program
{
private static void Main(string[] args)
{
IWebDriver driver;
Uri _internalSeleniumGrid = new Uri("http://x.x.x.x:4444/wd/hub");
FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions
{
UseLegacyImplementation = true
};
DesiredCapabilities capabilities = (DesiredCapabilities)options.ToCapabilities();
capabilities.SetCapability(FirefoxDriver.ProfileCapabilityName, profile.ToBase64String());
driver = new RemoteWebDriver(_internalSeleniumGrid, capabilities);
driver.Navigate().GoToUrl("http://www.google.com");
driver.Quit();
}
}
}
The same code snippet works when using 3.2.0 grid node
Issue reproducible with Java bindings as well
Problem is not related to Firefox browser, but it looks like its more of a code issue. I was able to reproduce this error with Selenium 3.2.0 and Selenium 3.3.1 as well.
public class Issue3644 {
public static void main(String[] args) throws MalformedURLException {
RemoteWebDriver driver = null;
try {
DesiredCapabilities firefox = new DesiredCapabilities();
firefox.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
FirefoxOptions options = new FirefoxOptions();
options.setLegacy(true);
options.addDesiredCapabilities(firefox);
Capabilities caps = options.toDesiredCapabilities();
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps);
driver.get("http://www.google.com");
System.err.println("Page Title ::" + driver.getTitle());
} finally {
if (driver != null) {
driver.quit();
}
}
}
}
On it. sigh
Fix has landed in 07f6b7a037e500a2c94c4a026dbcf202c695cc4c
@shs96c - The OP raised this bug against the .NET bindings, but the above commit takes care of fixing this in the Java bindings. Just thought I would call this out since I noticed that the issue is now closed, even though its really only partially fixed
@krmahadevan what is there to fix on the .NET side? This should be covered by the fix @shs96c just landed
@lmtierney - Dang! You are right.. the issue was in the grid part... My bad...
@shs96c Any chance of seeing this fix rolled out (v3.3.2?) anytime soon? We use a 3.x grid and have been an early adopter of releases (Java bindings) but do rely on legacy for FF while GeckoDriver is maturing.
You can set the system property webdriver.firefox.marionette to false. That's interpreted correctly.
Most helpful comment
@shs96c Any chance of seeing this fix rolled out (v3.3.2?) anytime soon? We use a 3.x grid and have been an early adopter of releases (Java bindings) but do rely on legacy for FF while GeckoDriver is maturing.