adapter information
adapter information
I'm trying to make a function that outputs the coordinates of the center of a repository item given that repository item (repo.blah for example), please help
Re: adapter information
Hi,
I believe you are looking for a code like this:
This code returns center x/y position of a given repo element, based of its client rectangle coordinates/size. If you want screen rectangle-based position, replace 'Location' keyword with 'ScreenLocation' keyword. Hope this helps?
I believe you are looking for a code like this:
Code: Select all
int xVal=repo.blah.Element.Location.X;
int yVal=repo.blah.Element.Location.Y;
int widthVal = repo.blah.Element.Size.Width/2;
int heightVal = repo.blah.Element.Size.Heigh/2;
int repoCenterXVal= xVal + widthVal;
int repoCenterYVal= yVal + heightVal;
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
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: adapter information
There's also an alternative using the Ranorex API, so you don't have to do all the math yourself:
Regards,
Alex
Ranorex Team
System.Drawing.Point screenLocation = Ranorex.Location.Center.GetScreenLocation(element);You can use any location (e.g. a custom one or even one including an image search) instead of the "Center" and there is also a GetElementLocation method in the Location class in case you don't want screen but relative coordinates.
Regards,
Alex
Ranorex Team
Re: adapter information
Thanks for the info Alex, that's definitely a useful tip!
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