How to get the Width and Height of Images or Elements using selenium webdriver

package SeleniumLearn.COM;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class ImageWidhtandHeight {
        public WebDriver driver;
     @Test
                public void WidthandHight() throws Exception {
                driver.get("http://www.seleniumlearn.com");
                driver.findElement(By.linkText("About Us")).click();
               

               Thread.sleep(9000);
                Dimension d=driver.findElement(By.className("image-style-none")).getSize();
                System.out.println("Width : "+  d.width); //Print the Width of the Image
                System.out.println("Height : "+ d.height); //Print the Height of the Image
                }
  @BeforeTest
           public void beforeTest() {
           driver= new FirefoxDriver();
           driver.manage().window().maximize();
           }
@AfterTest
           public void afterTest() {
           }    
       }

Tags: