Author - StudySection Post Views - 45 views
Arguments | chrome

ChromeOptions Class (Common Arguments and Methods)

ChromeOptions(Common Arguments and Methods) is a separate class in selenium that helps to manage options specific to the ChromeDriver. ChromeOptions is a class that extends MutableCapabilities. It was introduced with Selenium v3.6.0.

Why It is Required: ChromeOptions class is used to customize the settings of the chrome browser. We can disable-popup-blocking, make-default-browser, disable-extensions, incognito, check the version, and other changes to the browser using this class with the latest version selenium. By default, selenium starts with a fresh session of a browser that doesn’t have any settings, cookies, and history.

Frequently Used Methods and Arguments:

  1. start-maximized: This argument opens the chrome browser window in maximize mode.
  2. setPageLoadStrategy: This method is used to speed up execution. It is of three types Normal, None, and Eager.
    • Normal: In this mode, Selenium WebDriver wait for the entire page is loaded.
    • None: In this mode, Selenium WebDriver only waits until the initial page is downloaded.
    • Eager: Selenium WebDriver to wait until the initial HTML document has been completely loaded and parsed
  3. disable-infobars: This argument is used to remove the information bar/notifications from the browser. But this argument has been deprecated. We can use this line of code to remove the information bar from the browser.
    Code: options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
    infobar | Arguments
  4. Incognito: This argument is used to open a chrome browser in incognito mode. It helps to prevent history and cookies. Incognito mode deletes this data as soon as we close the web browser.
    map | Arguments
  5. Version: This argument is used to get the current version of the browser.
  6. Disable-popup-blocking: This argument is used to disable the popup in the chrome browser. We can block the popup using these methods:
    Code: options.setExperimentalOption(“excludeSwitches”,

    Code: options.addArguments(“–disable-popup-blocking”);
    Arguments |alert
    package Practise;
    import java.util.Arrays;
    import org.openqa.selenium.By;
    import org.openqa.selenium.PageLoadStrategy;
    import org.openqa.selenium.WebDriver;
    import io.github.bonigarcia.wdm.managers.ChromeDriverManager;
    public class Testing{
    public static WebDriver driver;
    public static void main(String arg[]) throws InterruptedException{
    // Creating ChromeOptions object
    ChromeOptions options = new ChromeOptions();
    // 1. Open browser window in maximize mode
    // 2. Add page load strategy
    // 3. Remove Infobars
    options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
    // 4. Open browser in Incognito mode
    // 5. Get current Version of Chrome
    // 6. Disable-popup-blocking
    // For use with ChromeDriver
    driver = new ChromeDriver(options);
    //Open URL

Knowledge of .NET is quite rewarding in the IT industry. If you have got some skills in the .NET framework then a .NET Certification Exams from StudySection can prove to be a good attachment with your resume. You can go for a foundation level certificate as well as an advanced level certificate in the .NET framework.

Leave a Reply

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