XPath: Conditions for the adapters themselves

Ask general questions here.
User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

XPath: Conditions for the adapters themselves

Post by testautomator » Tue Jul 22, 2014 8:11 am

Hi,
Can I have conditions for the adapters themselves and not attributes?
I know attributes can have conditions with in them. Ex: text[@name='name' and @visible='true']
Now, can i use condition for adapters?
Example: \form[@name='form1'] or element[@name='Popuppanel']\text[@text='sometext']\

We have situation where a group of objects appear with in a form or within a popup, all these objects are same. We dont want to add objects for both of these since they are duplicates. Now, we can eliminate the form and popup by just using '//' but this slows down the script.
So, is there a way to use conditions like above?

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: XPath: Conditions for the adapters themselves

Post by krstcs » Tue Jul 22, 2014 2:51 pm

Unfortunately, no, you can't use conditionals on adapters.

However, all adapters are based off of the element type, so you can just use "element" like below.

Code: Select all

/element[@name='form1' or @name='Popuppanel']/text[@text='sometext']
Shortcuts usually aren't...

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

Re: XPath: Conditions for the adapters themselves

Post by Support Team » Tue Jul 22, 2014 9:44 pm

Just a small correction: "element" in a RanoreXPath really only gets you "element" elements. If you want to get all elements regardless of their role, use the "*" operator, e.g.:

Code: Select all

/*[@name='form1' or @name='Popuppanel']/*[@text='sometext']
See the corresponding topic in the user guide for more information.

Regards,
Alex
Ranorex Team
.
Image

User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: XPath: Conditions for the adapters themselves

Post by testautomator » Wed Jul 23, 2014 6:31 am

Cool!!
Thanks krstcs and Alex. I have tried it and its working. Now, I have to check out the performance with or without the adapter conditions.

User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: XPath: Conditions for the adapters themselves

Post by testautomator » Wed Jul 23, 2014 7:29 am

I have tried and it looks like not much difference!! Maybe, we will do more tests. Run them in bulk and see if its faster or its same.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: XPath: Conditions for the adapters themselves

Post by krstcs » Wed Jul 23, 2014 4:10 pm

Excellent, I learn something new every day. :D

Thanks Alex!
Shortcuts usually aren't...