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

前端 未结 28 2212
悲&欢浪女
悲&欢浪女 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:47

    There's an outstanding issue to add this functionality to WebDriver, which can be tracked here: http://code.google.com/p/selenium/issues/detail?id=174

    A workaround would be to use the JavascriptExector as follows:

    public void resizeTest() {
        driver.Navigate().GoToUrl("http://www.example.com/");
    ((IJavaScriptExecutor)driver).ExecuteScript("window.resizeTo(1024, 768);");
    }
    

提交回复
热议问题