How to maximize the browser window in Selenium WebDriver (Selenium 2) using C#?

前端 未结 28 2219
悲&欢浪女
悲&欢浪女 2020-11-29 18:20

Is there any way to maximize the browser window using WebDriver (Selenium 2) with C#?

28条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 18:30

    driver.Manage().Window.Maximize();

    This works for IE and Firefox. Chrome does not work. There is a bug submitted for this on ChromeDriver project.

    Meanwhile, the get around for the chrome is to implement what Joey V. and Coder323 suggested.

    ChromeOptions options = new ChromeOptions();
    options.addArgument("--start-maximized");
    driver = new ChromeDriver(options);
    

提交回复
热议问题