selenium: I Can't set browserName for FirefoxDriver

System

Gecko Driver Version: 18.0 Platform: Win 10 Firefox: 54.0.1 Selenium WebDriver: 3.7.0 Program Language: C#

Issue

I have some problems with modified FireFox browser. When the Browser opens and I get an error:

[“System.ArgumentException” in WebDriver.dll] TypeError: Given browserName [object String] “firefox”, but my name is [object String] “anotherbrowser”

I think, it’s because of browser’s name “anotherbrowser” instead of “firefox” in it’s binary code.

So I found the solution on Java:

    FirefoxOptions options = new FirefoxOptions();
    options.setBinary("Path to browser binary");
    options.setCapability("browserName", "anotherbrowser");
    options.setCapability("marionette", false);
    driver = new FirefoxDriver(options);

I tested it, and its work fine. But I need on C#, so I tried to rewrite it: (1st code)

    DesiredCapabilities cap = DesiredCapabilities.Firefox();
    cap.SetCapability("firefox_binary", @"Path to Browser");
    cap.SetCapability(CapabilityType.BrowserName, "anotherbrowser");
    IWebDriver driver = new FirefoxDriver(cap);

I run the program and I got an error:

[“System.ArgumentException” in WebDriver.dll] There is already an option for the browserName capability. Please use the instead.

So I re-wrote my code: (2nd code)

    DesiredCapabilities cap = new DesiredCapabilities("anotherbrowser", "54.0.1", new Platform(PlatformType.Windows));
    cap.SetCapability("firefox_binary", @"Path to Browser");
    IWebDriver driver = new FirefoxDriver(cap);

And I got same error.

After I tried to test my codes with Selenium WebDriver 3.6.0.

I run 1st code and I got an error:

[“System.InvalidOperationException” in WebDriver.dll] Invalid moz:firefoxOptions field acceptInsecureCerts

Then I run 2nd code and I got another error:

[“System.InvalidOperationException” in WebDriver.dll] Invalid moz:firefoxOptions field browserName

Why isn’t it possible in C# to rewrite [browserName] to another, but in Java everything is okay? Please, help me to re-write Java solution to C#

P.s. I can’t use original Firefox browser, because it doesn’t have same advantages as my modified Firefox.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

@Lonckaster Try this code:

options.UseLegacyImplementation = true;
options.BrowserExecutableLocation = @"Path to Browser";
options.AddAdditionalCapability("browser", "anotherbrowser");
IWebDriver driver = new FirefoxDriver(options);