ChromeOptions in Selenium Webdriver

ChromeOptions is a class in Selenium that is used to set the capability and customization and configuration of the ChromeDriver session as well.  This class inherits the MutableCapabilities class.

How to add chrome options in selenium -> Just by creating an instance

ChromeOptions options = new ChromeOptions();

Uses of chrome options:

  • It is used to get and set capabilities in Chrome
  • Chrome Options supports adding the extension to the browser at runtime
  • It helps to add binary at runtime
  • ChromeOptions is used to handle the proxy while running test automation
  • We use ChromeOptions in Selenium Grid to remotely set the Chrome session in node machines

There are certain methods that are available in chrome options which we can call:

  • addArguments(arguments)
  • addEncodedExtensions()
  • addExtensions()
  • getCapability()
  • setCapability()
  • getPlatform()
  • setAcceptInsecureCerts()
  • setBinary()
  • setProxy()
  • setExperiementalOption()
  • setPageLoadStrategy()
  • setUnhandledPromptBehaviour()
  • getBrowserName()
  • getVersion()

Script Demo: (Demo : Add Arguments();)

Create the Instance: ChromeOptions options = new ChromeOptions();

You can maximize the window by default: options.AddArguments(“start–maximized”)

Calling the browser: Webdriver driver = new ChromeDriver(options)

Go to a website by using driver.get() method -> Browser will be opened as maximized by default

Leave a comment

Your email address will not be published. Required fields are marked *