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.
To detect the browser version on the client machine, your script can analyze the value of navigator. appVersion or navigator. userAgent.
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.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With