0

I am using Chrome driver on mac, and when opening the browser I have these options

WebDriver driver; 
@Before public void setup() { 
    ChromeOptions options = new ChromeOptions(); 
    options.addArguments("use-fake-ui-for-media-stream"); 
    options.addArguments("--disable-web-security"); 
    options.addArguments("--start-maximized"); 
    options.addArguments("disable-infobars"); 
    System.setProperty("webdriver.chrome.driver","/Users/animanukyan/Drivers/chromedriver"); 
    driver = new ChromeDriver(options); 
} 

but non of them seems to work, browser opens not maximized, infobars are there...

DebanjanB
  • 118,661
  • 30
  • 168
  • 217
anima
  • 3
  • 2

1 Answers1

0

Using ChromeDriver to open Chrome maximized and without infobars:

Previously we handled through the argument disable-infobars and you can find a couple of relevant discussions in:

But from Chrome v76.x onwards to suppress the infobars you have to:

  • Use an instance of ChromeOptions and addArguments to start-maximized.
  • Use ExperimentalOption to enable-automation.
  • Use ExperimentalOption to set useAutomationExtension as false.
  • You can find a detailed discussion in Unable to hide “Chrome is being controlled by automated software” infobar within Chrome v76

  • Code Block:

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    
    public class A_Chrome 
    {
        public static void main(String[] args) 
        {
            System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
            ChromeOptions options = new ChromeOptions();
            options.addArguments("start-maximized");
            options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
            options.setExperimentalOption("useAutomationExtension", false);
            WebDriver driver =  new ChromeDriver(options);
            driver.get("https://www.google.co.in");
            System.out.println(driver.getTitle());
            driver.quit();
        }
    }
    
  • Console Output:

    Google
    
  • Browser Snapshot:

ChromeOptions

DebanjanB
  • 118,661
  • 30
  • 168
  • 217
  • 1
    This worked for infobar, thanks!. And is there a way to allow camera access? – anima Dec 04 '19 at 08:28
  • @anima Great News !!! Glad to be able to help you out !!! Please [_accept_](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) the _answer_ by clicking on the hollow tick mark beside my _answer_ which is just below _votedown_ arrow, so the tick mark turns _green_. – DebanjanB Dec 04 '19 at 08:29
  • and is there a way to allow camera access as well? – anima Dec 04 '19 at 09:40