Search code examples
javaautomated-testsselenium-chromedriverwebdrivermanager-java

How to set Chrome Options when using WebDriverManager?


I'm using Web driver manager to setup chrome driver. When setting up the driver I want to add some chrome options? How can I do it when using web driver manager?

I checked the WebDriverManager API but couldn't find any clue..


Solution

  • public void WebDriverManagerTest()
    {
        //setup the chromedriver using WebDriverManager
        WebDriverManager.chromedriver().setup();
    
        //Create Chrome Options
        ChromeOptions option = new ChromeOptions();
        option.addArguments("--test-type");
        option.addArguments("--disable-popup-bloacking");
        DesiredCapabilities chrome = DesiredCapabilities.chrome();
        chrome.setJavascriptEnabled(true);
        option.setCapability(ChromeOptions.CAPABILITY, option);
    
        //Create driver object for Chrome
        WebDriver driver = new ChromeDriver(option);
    
        //Navigate to a URL
        driver.get("http://toolsqa.com");
    
        //quit the browser
        driver.quit();
    }
    

    Found the answer.. Check above!