WebElement

Selenium WebDriver : getSize() Vs getLocation()

In Selenium WebDriver getSize() and getLocation() methods are different:

getSize() : will return the “Dimension” object, from which we can get Height and Width of specific element
Dimension vDimesions = vDriver.findElement(By.id(“id“)).getSize();
System.out.println(“Height :” + vDimesions.height + ”Width : “+ vDimesions.width);

getLocation() : will return the “Point” object, from which we can get X and Y coordinates of specific element
Point vPoint=driver.findElement(By.id(“id”)).getLocation();

System.out.println(“X : “+ vPoint.x + “Y : “+ vPoint.y);