Is there a way to specify multiple types of elements?

Class library usage, coding and language questions.
esac
Posts: 3
Joined: Sat Sep 25, 2010 12:59 am

Is there a way to specify multiple types of elements?

Post by esac » Fri Oct 15, 2010 6:39 pm

I have a control which appears sometimes as one type, and at other times it appears as something else.

I know I can do /*[@title='foo']/button however it of course can match many elements, and I assume that the search time would be higher. Is there a way to say something like /(form|controlnet11)[@title='foo']/button

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

Re: Is there a way to specify multiple types of elements?

Post by Support Team » Mon Oct 18, 2010 1:36 pm

Hi,

Normally you don't get the "ControlNet11" elements, expect you don't start your application as administrator or the application is placed on the network. If you have a .Net 4 application you will get the "ControlNet11" elements too, but this is a known issue and we are currently searching for a solution.

Please check if the application is started as administrator if you get the "ControlNet11" elements and please check if your application don't use .Net 4 controls.

Regards,
Peter
Ranorex Team
.
Image

esac
Posts: 3
Joined: Sat Sep 25, 2010 12:59 am

Re: Is there a way to specify multiple types of elements?

Post by esac » Mon Oct 18, 2010 5:14 pm

We are definitely using .Net 4 controls and have already been in contact regarding a fix for this issue. Until then. Even with a fix, all of our controls are dynamically drawn, and what may be under a 'container' one time may be under a 'combobox' the next time, so it would be nice to be able to specify that.

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

Re: Is there a way to specify multiple types of elements?

Post by Support Team » Tue Oct 19, 2010 1:48 pm

Hi,

Of course you can use the character "*" in your RxPath instead of form or control. You have just to use more attributes inside the brackets, then the RxPath will identify your element with the expected attributes. The more attributes you use inside the brackets, the more robust will be your RxPath. In your example I would suggest you following
/*[@title='caption']/button[@text='button' and @controlname='WinformsButton'] for example. Also a possible solution would be to search your form/control/container as follow:
/*[@title='caption']/.//button[@text='button' and @controlname='WinformsButton']
If you use the RxPath above, Ranorex is searching the whole element for this item.

Regards,
Peter
Ranorex Team
.
Image