How To Find Web Elements X Y Coordinates Using Selenium WebDriver

Finding Web Elements X Y Coordinates Using Selenium:

Any web element has its own position on page known as x y coordinates. x y coordinates of a web element is measured in x and y pixels. x pixels means the horizontal position of an element on a page from the left side and y pixels means the vertical position of an element on a page from the top. Let’s see how to find web elements x y coordinates using Selenium WebDriver.

By using Point class we could get the web elements x y coordinates in Selenium WebDriver.

Also Read: SQL Tutorial for Software Testers

Let’s see a practical example on how to find web elements x y coordinates using Selenium WebDriver:

Given clear explanation in the comments section within the program itself. Please go through it to understand the flow.

Execute the above script and see the console output. You could see the values of x and y coordinates.

Also, see how to get the size of an element in Selenium WebDriver:

To get the width and height of an element, I have used getSize() method

Practical Example:

Given clear explanation in the comments section within the program itself. Please go through it to understand the flow.

Execute the above script and see the console output. You could see the width and height of the logo.

If you are not a regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

2 thoughts on “How To Find Web Elements X Y Coordinates Using Selenium WebDriver”

    • Hi Hema, Use the below code..
      Use Action class and pass x, y coordinates
      Actions action = new Actions(driver);
      action.moveToElement(element, xcord, ycord).click().build().perform();

      Reply

Leave a Comment

Share via
Copy link
Powered by Social Snap