Using optional element

Ranorex Studio, Spy, Recorder, and Driver.
niteshr
Posts: 18
Joined: Fri Jul 11, 2014 7:41 am

Using optional element

Post by niteshr » Thu Oct 16, 2014 9:15 am

Hi Guys,

I've worked on a project in the past and the UI has the following structure:

I set the domain via a variable at the top level. The example below is a textbox items XPath in the crrent repository.

/dom[@domain=$varDomain]//input[#'username']

So i'm working on a new project now and I want to use the same repository items. However, the difference in the UI is an IFrame. See below:

/dom[@caption='Page']//iframe[@id='iFrame']//input[#'username']

I am trying the following in Ranorex Spy to track the item on the new UI but it is not detecting. Please point me in the right direction. The below Xpath works on the old UI but not the new one:

/dom[@domain=$varDomain or @caption='Page']/?//input[#'username']

If I replace the question mark with the iframe[@id=@iFrame'] it detects the element. I thought the whole point of the ? was so it will be regaded as an optional element. Please help me asap. Thanks

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Using optional element

Post by odklizec » Thu Oct 16, 2014 11:32 am

Hi,

Try add the question mark after the iframe, like this...
iframe[@id=@iFrame']?
Pavel Kudrys
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

niteshr
Posts: 18
Joined: Fri Jul 11, 2014 7:41 am

Re: Using optional element

Post by niteshr » Thu Oct 16, 2014 12:08 pm

No luck I'm afarid. The spy tool doesn't like that syntax. I'm trying to cut out referring to the IFrame as it doesn't exist in the first project. I changed the textbox's axis to descendant instead of child and I am able to highlight the element in the spy but when I run my test the element is not detected. Why would this be?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Using optional element

Post by odklizec » Thu Oct 16, 2014 12:36 pm

OK, sorry, I was out of the PC and I thought it could be used like this. This one should work then ;)
iframe?[@id='iFrame']

So the whole path should be like this:
/dom[@domain=$varDomain or @caption='Page']//iframe?[@id='iFrame']//input[#'username']
Pavel Kudrys
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

niteshr
Posts: 18
Joined: Fri Jul 11, 2014 7:41 am

Re: Using optional element

Post by niteshr » Thu Oct 16, 2014 2:16 pm

Thanks again. I need to exclude the IFrame though. I'm afraid this is a case of the spy detecting the element but the Ranorex studio can't. No idea how to solve this at the moment :(

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Using optional element

Post by Support Team » Mon Oct 20, 2014 1:46 pm

Hello guys,

I assume that the mentioned paths
  • "/dom[@domain=$varDomain]//input[#'username']"
    and
    "/dom[@caption='Page']//iframe[@id='iFrame']//input[#'username']"
uniquely identify the input element on the old and new UI, respectively.


Using the following path you should be able to find the element on both UIs:
  • /dom[@domain=$varDomain or @caption='Page']//input[#'username']
The .//input is the relative path identifying all input elements that are descendants of the current element. Depending on the structure of your application, this can be quite time-consuming.

If you are still facing issues, please contact [email protected]

Regards,
Robert

niteshr
Posts: 18
Joined: Fri Jul 11, 2014 7:41 am

Re: Using optional element

Post by niteshr » Tue Nov 04, 2014 9:14 am

Thanks for that. Unfortunately, still no luck. I read in this post http://www.ranorex.com/forum/bug-unique ... t6173.html that an IFrame has a different scope from the dom. I'm assuming that is my issue. I have emailed the support team but got no feedback yet. I don't wan't to replicate my repository items and recordings. Please help me with an alternative solution

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

Re: Using optional element

Post by krstcs » Tue Nov 04, 2014 5:57 pm

niteshr,

Have you tried just adding "//iframe" in the middle of your path just to see if it will work?

/dom[@domain=$varDomain or @caption='Page']//iframe//input[#'username']


If it does work, then maybe that will fix the issue, it did for me.
Shortcuts usually aren't...