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

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

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

28条回答
  •  旧时难觅i
    2020-11-29 18:28

    Test step/scenario:
    1. Open a browser and navigate to TestURL
    2. Maximize the browser

    Maximize the browser with C# (.NET):

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

    Maximize the browser with Java :

    driver.manage().window().maximize();
    

    Another way to do with Java:

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension screenResolution = new Dimension((int) 
                        toolkit.getScreenSize().getWidth(), (int) 
                        toolkit.getScreenSize().getHeight());
    
    driver.manage().window().setSize(screenResolution);
    

提交回复
热议问题