Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
1.6k views
by Contributing Tester (92 points)
edited by

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 like 0 dislike
by The go-to Tester (181 points)
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.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...