how to search for an element in a specific region

Best practices, code snippets for common functionality, examples, and guidelines.
wyll
Posts: 34
Joined: Wed Aug 01, 2012 3:19 pm

how to search for an element in a specific region

Post by wyll » Wed Aug 22, 2012 11:26 am

Hi,

what i want to know is, if there is a way to search for an element in the lower half of the screen or generell in a specific region, you selected before.

regards
wyll

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to search for an element in a specific region

Post by Support Team » Wed Aug 22, 2012 11:36 am

Hi,

therefore please have a look at following chapter of our user guide:
RanoreXPath

In the "Functions" section you will see the x() and y() functions. Using this functions within a RanoreXPath you are able to identify elements based on there location.

So, as mentioned in the user guide, the RanoreXPath "/form[x()>100 and y()>100]" will identify all top level application with screen coordinates greater than 100.

Regards,
Tobias
Ranorex Team
.
Image

wyll
Posts: 34
Joined: Wed Aug 01, 2012 3:19 pm

Re: how to search for an element in a specific region

Post by wyll » Wed Aug 22, 2012 1:26 pm

Thanks a bunch,

is there also a way to write that in a usercode?
for example

int mycriteria = 100;

[y()>0 and x()>mycriteria]

regards wyll

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to search for an element in a specific region

Post by Support Team » Wed Aug 22, 2012 1:31 pm

Hi,
wyll wrote:is there also a way to write that in a usercode?
Of course:
int mycriteria = 100;
Host.Local.FindSingle("RXPath/To/Your/element[y()>0 and x()>" + mycriteria.ToString() + " ]");
Regards,
Tobias
Ranorex Team
.
Image

wyll
Posts: 34
Joined: Wed Aug 01, 2012 3:19 pm

Re: how to search for an element in a specific region

Post by wyll » Wed Aug 22, 2012 1:48 pm

sweet,
thank you very much tobias