Wednesday, January 14, 2015

How to find out the selenium Element X, Y Coordinate

AS we know that every web pages on the website has own coordinate (x, y) to find out the x, y coordinate  we have you use “Point” interface in the selenium. AS we all know that in C language we use Pointer to get the reference or address for any variable in the program . Similar in the selenium we use “Point ” reference such as

 WebElement element = driver.findElement(By.xpath("//img[@border='0']"));
       Point point = element.getLocation();
        int xcord = point.getX();
        int ycord = point.getY();
        System.out.println("Element's Position from left side Is "+xcord +" pixels."+"+ycord +" pixels.");
        

No comments:

Post a Comment