marifrahman marifrahman - 9 months ago 70
C# Question

How to get the Browser info in C# WebDriver?

I see a ICapabilities interface to get the Browser info;Did couple of googling with no luck for any code example; Can anybody please share anything how I can get the browser info for a particular IWebDriver instance ? I am using C# webdriver.

Answer Source

In order to get info defined in ICapabilities interface, you need to cast IWebDriver instance to RemoteWebDriver. Then you can get the info about BrowserName, IsJavaScriptEnabled, Platform and Version.

IWebDriver driver = new FirefoxDriver();
ICapabilities capabilities = ((RemoteWebDriver)driver).Capabilities;

// then you have
// capabilities.BrowserName;
// capabilities.IsJavaScriptEnabled;
// capabilities.Platform;
// capabilities.Version;