Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 689
marifrahman Avatar asked Apr 30 '13 04:04

marifrahman


People also ask

How can you find out the version information of the client's browser?

To detect the browser version on the client machine, your script can analyze the value of navigator. appVersion or navigator. userAgent.

How to check browser version in js?

Use the userAgent to Detect Browser Version in JavaScript Copy const { userAgent } = navigator console. log(userAgent); Using the includes method will take a string as a parameter to return it. This string helps in detecting the browser as follows.

What is userAgent sniffing?

User-Agent (UA) Sniffing UA Sniffing usually involves searching for a specific string or pattern in the UA string and basing choices on the result of that search. A popular example from real life is: var isiPhone = /iPhone/i. test(navigator.


1 Answers

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;
like image 157
Yi Zeng Avatar answered Oct 02 '22 14:10

Yi Zeng