Hi,
I am having an application in which there are few Radiobuttons at a paticular Page. Now i want to know there positions i.e I want to know that which is first and which is second and so on.
And I want to tell that which is to the right for example: Radio button1 and Radio button2 are there now how will I check that Radio Button1 is left to Radio Button2 or vice verca?
For addtion will I be able to get there co-ordinates and store them?
And is there a way to highlight an object during execution?
Thanks In Advance.
Deepak
How to Check Which Element of Same Type is first
-
- Posts: 76
- Joined: Fri Mar 14, 2014 2:37 pm
Re: How to Check Which Element of Same Type is first
Hi,
I don't think there is a way to highlight the objects during playback? But I never looked for such option so I could be wrong about this
As for getting object coordinates, you can use something like this:
I don't think there is a way to highlight the objects during playback? But I never looked for such option so I could be wrong about this
As for getting object coordinates, you can use something like this:
Ranorex.Button btnStart = "/button[@accessiblename='OK']"; int xPos = btnStart.ScreenRectangle.X; int yPos = btnStart.ScreenRectangle.Y; System.Diagnostics.Debug.WriteLine("xPos: " + xPos.ToString() + "\n" + "yPos: " + yPos.ToString() + "\n");
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: How to Check Which Element of Same Type is first
Hi,
Highlighting is possible since Ranorex 4.1: http://www.ranorex.com/forum/highlight- ... t2623.html
Best Regards
Zoltán
Highlighting is possible since Ranorex 4.1: http://www.ranorex.com/forum/highlight- ... t2623.html
Best Regards
Zoltán
-
- Posts: 76
- Joined: Fri Mar 14, 2014 2:37 pm
Re: How to Check Which Element of Same Type is first
Hi,
Thanks both of you for ur help. Helped me a lot...
But i would like to add that what if its not a button.
Lets say Its a text box or something like a rectangle then how will i get the x and y coordinates of all the 4 points
And after getting coordinates how will we compare in such a way that i can say that this rectangle is above this rectangle.
like username field is above password field.
can you provide me a little help...
Thanks in advance,
Deepak
Thanks both of you for ur help. Helped me a lot...
But i would like to add that what if its not a button.
Lets say Its a text box or something like a rectangle then how will i get the x and y coordinates of all the 4 points
And after getting coordinates how will we compare in such a way that i can say that this rectangle is above this rectangle.
like username field is above password field.
can you provide me a little help...
Thanks in advance,
Deepak
Re: How to Check Which Element of Same Type is first
Hi,
The same as X,Y coordinates, you can get also Width and Height of required element. This way you can get entire screen rectangle. Now if you need separate x/x values for each rectangle corner, then all you need to do is to calculate them using x/y and width/height values: Hope this helps?
The same as X,Y coordinates, you can get also Width and Height of required element. This way you can get entire screen rectangle. Now if you need separate x/x values for each rectangle corner, then all you need to do is to calculate them using x/y and width/height values: Hope this helps?
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: How to Check Which Element of Same Type is first
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.
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.
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));
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.
-
- Posts: 76
- Joined: Fri Mar 14, 2014 2:37 pm
Re: How to Check Which Element of Same Type is first
Thanks a lot, You guys rock.