Selenium Java to demonstrate the use of ChromeOptions class
KW.java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

class KW
{
    public static void main(String[] args) 
    {   
        System.setProperty("webdriver.chrome.driver", "/home/kodingwindow/drivers/chromedriver");
        ChromeOptions co = new ChromeOptions();
        
        // This argument used to open Chrome in maximized mode
        co.addArguments("--start-maximized");
        
        // This argument used to open Chrome in an incognito mode
        co.addArguments("--incognito");
        
        // This line used to disable pop-ups
        co.addArguments("--disable-popup-blocking");
        
        // This two lines prevents Chrome from displaying the notification 'Chrome is being controlled by automated software'
        co.setExperimentalOption("useAutomationExtension", false);
        co.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"}); 
        
        // This argument used to set the size of Chrome browser window
        co.addArguments("window-size=700,700");

        WebDriver driver = new ChromeDriver(co);
        
        driver.get("https://kodingwindow.com/testapp/");
        driver.close();
    }
}
Advertisement