Page 1 of 1

How to get coordinates for an object ?

Posted: Mon Dec 15, 2014 3:25 pm
by rastek
Hi

I need coordinates for some objects, but when I spy on objects I cant not see anything for coordinates.

Is there a way for this in Ranorex ?

Thank,
Rastek.

Re: How to get coordinates for an object ?

Posted: Mon Dec 15, 2014 3:36 pm
by krstcs
Use the repo object's element location or screenlocation properties. Location is relative to the parent element, while screenlocation is relative to the whole screen.

Code: Select all

MyRepoObject.Element.Location.X
MyRepoObject.Element.Location.Y

MyRepoObject.Element.ScreenLocation.X
MyRepoObject.Element.ScreenLocation.Y

Re: How to get coordinates for an object ?

Posted: Mon Jan 12, 2015 8:58 am
by ViMac
Could you help me, please?
code:

Code: Select all

gridTravelOptRet.Element.Location.X;
gridTravelOptRet.Element.Location.Y;
gridTravelOptRet.Element.ScreenLocation.X;
gridTravelOptRet.Element.ScreenLocation.Y;
Error:
only assignment call increment decrement await and new object expressions can be used as a statement.


Please tell me how to write the code that does it right?

Re: How to get coordinates for an object ?

Posted: Mon Jan 12, 2015 4:12 pm
by Ciege
You need to set the value of a variable to the result of the element information...

Code: Select all

int locationX = gridTravelOptRet.Element.Location.X;
int locationY = gridTravelOptRet.Element.Location.Y;
int screenLocationX = gridTravelOptRet.Element.ScreenLocation.X;
int ScreenLocationY = gridTravelOptRet.Element.ScreenLocation.Y;

Re: How to get coordinates for an object ?

Posted: Tue Jan 20, 2015 10:26 am
by ViMac
You just right, but I can not locate the object with the parameters which. Because that are the coordinates of the screen, each screen has different coordinates.
I still have no solution to the problem when the object value changes over timer and do not follow a rule. Please, Could you help me?

Re: How to get coordinates for an object ?

Posted: Tue Jan 20, 2015 5:39 pm
by Ciege
I'm not sure what issue you are having now. Can you be a little more clear?
Are you wondering how to find the location of an object on different screens? You will need to get that at runtime when you visit that screen. If the "object values change overtime" I assume you mean the object moves and is never in the same place twice. In that case, again, you need to check the location of the object at runtime, you cannot store that value and expect it to work the same each and every time.

Re: How to get coordinates for an object ?

Posted: Wed Jan 21, 2015 4:45 am
by ViMac
My issue:
To day, 01-21-2015 .To begin creating a reservation with:
Form "FindingFlights"
[*]Depart date: +2 date compare to now date.
[*]Return date: +4 date compare to now date.
Form "SelectingFlights"
[*]Depart: select an object with value 16,U,O
[*]Return: select an object with value 21,U,O
But date 01-22-2015 I run again, that value has changes. I am wondering how to locate an object of "SelectingFlights" form. :?:
Please,let me know any question for you to better my problem.

Re: How to get coordinates for an object ?

Posted: Tue Jan 27, 2015 10:20 am
by Support Team
Hi ViMac,

It would help a log if you could post a Ranorex Snapshot from your application and a detailed description. If you have already a Ranorex Solution it would also be great if you could provide your solution.
Unfortunately it is very difficult to help you solving your issue with the given information.

Regards,
Bernhard

Re: How to get coordinates for an object ?

Posted: Thu Feb 05, 2015 9:21 am
by ViMac
The problem I am having is that the value of the option changes through each day (attached below). I would like to locate and select one of them, but the option to change every day, it's not supposed to change. Suddenly, I have a solution is to use the function if .... else.
EX:
var gridTravelOptDep = repo.CMAReservationsSiteSearchFlights1.GridTravelOptDep;
if(gridTravelOptDep.Value =="6,U,O"){
gridTravelOptDep.Focus();
gridTravelOptDep.Click();
}
else if(gridTravelOptDep.Value =="7,U,O"){
gridTravelOptDep.Focus();
gridTravelOptDep.Click();
}
else if(gridTravelOptDep.Value =="10,R,O"){
gridTravelOptDep.Focus();
gridTravelOptDep.Click();
}
Please advise if that solution is okay?

Re: How to get coordinates for an object ?

Posted: Thu Feb 05, 2015 10:31 pm
by Ciege
It seems to me you time would be best spent with your dev team to determine what the values mean, why and when they change so that you can accurately code for the different values of the radio buttons. Blindly coding a bunch of if statements is not a reliable solution. What if you didn't code for the right value? What if multiple values appear that you have if's for?
In my not so humble opinion, you really should spend some time understanding how your AUT works so you know how to test it.