Hi Deepak,
Every element, you create in ranorex has the ScreenRectangle.X and ScreenRectangle.Y and also the
ScreenRectangle.Width and ScreenRectangle.Height proprties. With these information, you can calculate these elements relative position.
Based on odklizec comment, this should be the procedure to check for two elements position:
1. Get the first elements' X,Y,Width and Height properties
2. Get the second elements' X,Y,Width and Height properties
3. Compare the coordinates.
For example, if we want to see if element1 is above element2, the elements are starting at the same horizontal position and they have the same width.
Code: Select all
//get the info on element1
Ranorex.Element element1 = "/input[@id='username']";
int xPos_1 = element1.ScreenRectangle.X;
int yPos_1 = element1.ScreenRectangle.Y;
int width_1 = element1.ScreenRectangle.Width;
int height_1= element1.ScreenRectangle.Height;
//get the info on element2
Ranorex.Element element2 = "/input[@id='password']";
int xPos_2 = element1.ScreenRectangle.X;
int yPos_2 = element1.ScreenRectangle.Y;
int width_2 = element1.ScreenRectangle.Width;
int height_2= element1.ScreenRectangle.Height;
//the following boolean expressions can be used
//the check if element1 is above element2
bool is_above = ((yPos_1+width_1) > yPos_2);
//the check if element1 and element2 has the same starting position, and the same width
bool is_in_good_shape = ((xPos_1 == xPos_2) && (width_1 == width_2));
Hope this helps,
Zoltán Major
Ps1: I used the Ranorex API reference to get the info I needed:
http://www.ranorex.com/Documentation/Ranorex/
For everthing else, there is .NETreference:
http://msdn.microsoft.com/en-us/library/1zk39146
PS2: I used the most generic, element class to create the adapter for the input field. But I suggest to always try to use the proper element adapter, like the InputTag in.