getSize method will be used to get the dimension of webelement components on the webpage.
JAVA API Syntax : Dimension getSize()
This class consists the height and width of the webelement which means the dimension of the web element.
Code:
JAVA API Syntax : Dimension getSize()
This class consists the height and width of the webelement which means the dimension of the web element.
Code:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.*;
public class gtSize {
private static WebDriver driver = null;
public static void main(String[] args){
//setting the property for chrome browser and to invoke the chrome browser
System.setProperty("webdriver.chrome.driver",
"C://Selenium//chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.yahoo.com");
//Retrieving height and width of the Web Element for Yahoo logo - The Dimension
WebElement Ysize = driver.findElement(By.id("yucs-logo-ani"));
//Printing the result into the console for height and width
System.out.println(Ysize.getSize());
}
}
Output:
Starting ChromeDriver (vx.x.241075) on port 35952 (142, 37)