How to get the Current window Size using Selenium Webdriver?

后端 未结 4 623
粉色の甜心
粉色の甜心 2021-01-12 20:25

I am running on Screen Resolution of (1366 X 768 ), but when I call getSize().getWidth() and getSize().getHeight() methods , the result I\'m gettin

4条回答
  •  一向
    一向 (楼主)
    2021-01-12 21:00

    As we know Selenium interacts with browsers and these get methods will retrieve info related to browsers only. As explained in other answers very clearly, screen resolution and browser are different. The simple example below shows very clearly that the web driver is getting only the browser's dimensions.

        WebDriver driver=new FirefoxDriver();
        driver.get("http://www.google.com");
        System.out.println(driver.manage().window().getSize()); //output: (994, 718)
    
        driver.manage().window().maximize();
        System.out.println(driver.manage().window().getSize()); //output: (1382, 744)
    

提交回复
热议问题