Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The release notes for ChromeDriver 2.33 says that ""Fixes a bug which caused Resizing/Positioning Window commands to fail on Chrome 62+" however this still seems to be an issue when i am using Chrome 62+ browser. Maximizing chrome window using chrome driver results in below exception. Does anyone know a solution please?

Another thing i noticed is, though i installed latest chromedriver (v2.33) from https://chromedriver.storage.googleapis.com/index.html?path=2.33/, the log printed below says Driver info: chromedriver=2.25.426923 !!

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html (Session info: chrome=62.0.3202.62) (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

There are exactly 2 issues.

  1. As you mentioned, you have installed latest chromedriver (v2.33) but the log printed below says Driver info: chromedriver=2.25.426923, this issue must be addressed first. You can consider to manually kill all the dangling chromedriver.exe tasks from the Task Manager. Additionally you can consider to use CCleaner to wipe out all the rotten OS stuffs from your system. Take a system reboot if required. Finally ensure that what ever the absolute location of chromedriver.exe you are using within System.setProperty() ensure that the chromedriver binary is of version 2.33.

  2. Finally, it is suggested to use ChromeOptions class to maximize the Web Browser as follows:

    System.setProperty("webdriver.chrome.driver", "C:\your_directory\chromedriver.exe");
    ChromeOptions opt = new ChromeOptions();
    opt.addArguments("disable-infobars");
    opt.addArguments("--start-maximized");
    opt.addArguments("--disable-extensions");
    WebDriver driver = new ChromeDriver(opt);
    driver.get("https://google.com");
    
  3. Here are some of the alternatives which may solve your question:

    • Using maximize() from WebDriver.Window interface :

      driver.manage().window().maximize();
      
    • Using setSize(Dimension targetSize) from WebDriver.Window interface:

      driver.manage().window().setSize(new Dimension(800, 600));
      
    • Using addArguments("--start-maximized") through ChromeOptions:

      chromeOptions.addArguments("--start-maximized");
      
    • Using addArguments("--window-size=1920,1080") through ChromeOptions:

      chromeOptions.addArguments("--window-size=1920,1080");
      
    • Using executeScript() from JavaScriptExecutor interface:

      ((JavaScriptExecutor)driver).executeScript("window.resizeTo(1024, 768);");
      
  4. You can find a related discussion in Chrome - org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension at driver.manage().window().maximize();.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...