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

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

    Through the below code i'm able to maximize the window,

    ((JavascriptExecutor) driver).executeScript("if(window.screen){
        window.moveTo(0, 0);
        window.resizeTo(window.screen.availWidth, window.screen.availHeight);
        };");
    

提交回复
热议问题