O'Reilly logo

Selenium WebDriver Recipes in C#, Second Edition by Zhimin Zhan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required