Do you have questions ? We got the answers!

Ask a question:

0
Getting exception of type 'System.InvalidOperationException' occurred in WebDriver.dll when initializing RemoteWebDriver

Open 1 Answers 94 Views

I am getting this exception in initializing RemoteWebDriver instance.

Using C# with Selenium

Please see code snippet below.

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;

namespace FF
{
internal class Test
{
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("www.google.com");
        driver.Quit();
    }
}
}

 

Exception:

'System.InvalidOperationException' occurred in WebDriver.dll when initializing RemoteWebDriver

1 Answer

1
DesiredCapabilities capabilities = (DesiredCapabilities)options.ToCapabilities();

You can simply use

ICapabilities capabilities = options.ToCapabilities();

Rest of stuff looks good.

Also,

driver.Navigate().GoToUrl("http://www.google.com");

You will need protocol in the URL.

answered Mar 17 by stbadmin (4,970 points)

Top Contributors

  • 4970 pointsstbadmin

    34 questions 454 answers218 comments

  • 433 pointsSunilBhaskar

    41 questions 15 answers32 comments

  • 425 pointsMehedi

    36 questions 3 answers14 comments

  • 364 pointssumitkumarwatts

    0 questions 14 answers0 comments

  • 354 pointsSoft Tester

    43 questions 0 answers4 comments

  • 327 pointsKeeshaGolden

    0 questions 17 answers2 comments

  • 322 pointsVipul Sharma

    44 questions 0 answers24 comments

  • 310 pointsvysh.sharma

    25 questions 0 answers0 comments

  • 267 pointsOnkar_Nimje

    33 questions 15 answers15 comments

  • 258 pointsVanitha

    26 questions 0 answers6 comments

...