CHAPTER 16

image

Browser Profile

Selenium WebDriver can start browser instances with various profile preferences, which can be quite useful. Obviously, some preference settings are browser specific, so you should take some time to explore. In this chapter, I cover some common usage.

Get browser type and version

Detecting browser type and version is useful to write custom test scripts for different browsers.

driver = new FirefoxDriver();ICapabilities caps = ((RemoteWebDriver)driver).Capabilities;String browserName = caps.BrowserName;String browserVersion = caps.Version;Console.WriteLine("browserName = " + browserName);      // firefoxConsole.WriteLine("browserVersion ...

Get Selenium WebDriver Recipes in C#, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.