getLocation() Method

This getLocation method is used to get where the webelement is provied on the web page.  The location is exactly where the (X, Y) axis is located for the particular webelement.

JAVA API Syntax : Point getLocation()


getLocation method will provide the exact point of X and Y axis.


Try the below to get the geometrical location


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 gtLocation {
 
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();

//Launching yahoo website
driver.get("http://www.yahoo.com");

//Retrieving Yahoo logo location X and Y axis
WebElement Ylocation = driver.findElement(By.id("yucs-logo-ani"));

//Printing the result into the console for X and Y location
System.out.println(Ylocation.getLocation());

}
}
Output:
Starting ChromeDriver (vx.x.221075) on port 23363
(0, 47)
Socialize It and Share the post with your friends
SOCIALIZE IT →
FOLLOW US →
SHARE IT →