-1

our automation need to check the element location on screen ( map them if possible) for example :

  1. check the text box 'x' is on top and on the right side of the checkbox 'y'
  2. checkbox 'z' is near the the label 'q' and below it 3.....

is there a robust way to do it , that will hold on all browsers + resolution ?

  • There are a number of javascript approaches you can try here: http://stackoverflow.com/questions/442404/retrieve-the-position-x-y-of-an-html-element – Richard May 09 '14 at 19:29

1 Answers1

1

You can use the Location property.

First, you'll need to add the .net reference for System.Drawing to your project. Then, you'll need to add using System.Drawing; to the .cs

Point xRef = driver.FindElement(By()).Location;
Point xRef = driver.FindElement(By()).Location;

Then you can reference Point.X and Point.Y to determine coordinates, and compare to other references.

if(xRef.Y < yRef.Y && xRef.X > yRef.X)
Richard
  • 8,961
  • 3
  • 38
  • 47