How to get current size window using Selenium Webdriver?

I run the screen resolution (1366 X 768), but when I call the getSize () getWidth () and getSize () getHeight () methods, the result is: Size Width: 1382 Size Height: 744 for IE, FF and Chrome web pages. URL used: https://www.google.com

+4
source share
4 answers

As you know, selenium interacts with browsers, and this get method will receive information related only to browsers. As explained in another answer, the screen resolution and browser are very clear. Below a simple example, it is very clearly stated that webdriver only gets browser sizes.

    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)

Thanks Murali

+4
source

.

( wikipedia)

, - , ... "1024 × 768" , 1024 , - 768 .

getSize() .

+3
    Dimension initial_size = driver.manage().window().getSize();
    int height = initial_size.getHeight();
    int width = initial_size.getHeight();
+2

python selenium webdriver get_window_size:

driver.get_window_size()
"""
Output:
{
  "width": 1255,
  "height": 847,
  "hCode": 939524096,
  "class": "org.openqa.selenium.Dimension"
}
"""
+1

All Articles