Thursday, 9 February 2017

SELENIUM: How To Get Height And Width Of Element


How To Get Height And Width Of Element:



package com.rameshsoft.rameshselenium;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class HightAndWidthDemo {
                   public static void main(String[] args) throws Exception {
                             System.setProperty("webdriver.gecko.driver", "C:\\Users\\ramesh\\Desktop\\java\\desk\\geckodriver-v0.11.1-win64\\geckodriver.exe");
                             WebDriver driver=new FirefoxDriver();
                             driver.manage().window().maximize();
                             driver.manage().timeouts().implicitlyWait(55,TimeUnit.SECONDS);
                             driver.manage().deleteAllCookies();
                             driver.navigate().to("https://www.gmail.com");
                             Thread.sleep(2000);
                             WebElement ele=driver.findElement(By.id("Email"));
                   int x_hight=ele.getSize().height;
                   int x_width=ele.getSize().width;
                   System.out.println(x_hight+"........."+x_width);
                   driver.quit();

}
}

No comments:

Post a Comment