Author - StudySection Post Views - 1,705 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
     Arguments|without-infobar
  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”,
    Arrays.asList(“disable-popup-blocking”));

    Code: options.addArguments(“–disable-popup-blocking”);
    Arguments |alert
    Code:
    package Practise;
    import java.util.Arrays;
    import org.openqa.selenium.By;
    import org.openqa.selenium.PageLoadStrategy;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import io.github.bonigarcia.wdm.managers.ChromeDriverManager;
    public class Testing{
    public static WebDriver driver;
    public static void main(String arg[]) throws InterruptedException{
    ChromeDriverManager.chromedriver().setup();
    // Creating ChromeOptions object
    ChromeOptions options = new ChromeOptions();
    // 1. Open browser window in maximize mode
    options.addArguments("--start-maximized");
    // 2. Add page load strategy
    options.setPageLoadStrategy(PageLoadStrategy.EAGER);
    // 3. Remove Infobars
    options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
    // 4. Open browser in Incognito mode
    options.addArguments("--incognito");
    // 5. Get current Version of Chrome
    options.addArguments("--version");
    // 6. Disable-popup-blocking
    //options.setExperimentalOption("excludeSwitches",
    //Arrays.asList("disable-popup-blocking"));
    options.addArguments("--disable-popup-blocking");
    // For use with ChromeDriver
    driver = new ChromeDriver(options);
    //Open URL
    driver.get("https://www.google.com/maps");
    Thread.sleep(5000);
    driver.findElement(By.xpath("//*[@id='widget-mylocation']")).click();
    }
    }

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 *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri