Object with two different xpaths concurrently?

Ask general questions here.
npanag
Posts: 33
Joined: Thu Jun 02, 2016 5:42 pm

Object with two different xpaths concurrently?

Post by npanag » Wed Oct 05, 2016 1:03 pm

I test a web application that has Companies and Funds accessing a similar form. For example Company Details and Fund Details. One box in the detailed form is the Name box.

Fund Detail name box
==================
/dom[@domain='frontinvesttest:8080']//td[#'framescontainer']/div//table/tbody/tr/td/table/tbody/tr//div[@id='id_controls_area']/div/input[@ajxnameid~'^###FUND[0-9]_[0-9]_[0-9][0-9][0-9]' and @type='text']

and
Company Detail name box
======================
/dom[@domain='frontinvesttest:8080']//td[#'framescontainer']/div//table/tbody/tr/td/table/tbody/tr//div[@id='id_controls_area']/div/input[@ajxnameid~'^###RT_NAME1_2_[0-9][0-9][0-9]' and @type='text']

Is there a way to have both definitions of the same object with different names and different xpaths in the same repository?

Basically i have organized the test with two different solutions and I want to try to merge the two solutions into one. I open the first solution and I try to import a recording from the second test. Here is the problem: The second test (Funds) goes inside the first (Companies) without the Fund references. The company detail name box somehow prevails to Fund detail name box and I have only the first xpath.

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

Re: Object with two different xpaths concurrently?

Post by odklizec » Wed Oct 05, 2016 1:53 pm

Hi,

I believe you can use xpath like this:
/dom[@domain='frontinvesttest:8080']//td[#'framescontainer']/div//table/tbody/tr/td/table/tbody/tr//div[@id='id_controls_area']/div/input[@ajxnameid~'^(###RT_NAME1_2|###FUND[0-9]_[0-9])_[0-9][0-9][0-9]' and @type='text']
You see, below regex should match either ###RT_NAME1_2_123 or ###FUND1_1_123
^(###RT_NAME1_2|###FUND[0-9]_[0-9])_[0-9][0-9][0-9]
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

npanag
Posts: 33
Joined: Thu Jun 02, 2016 5:42 pm

Re: Object with two different xpaths concurrently?

Post by npanag » Wed Oct 05, 2016 6:36 pm

Thank you for your help, but my problem is that the two commands are in the same menu (see the attachment). So, when I test it in Spy it returns two valid elements, one for companies and the other for funds.

How the program knows if you want to select the companies or the funds?
Attachments
Open_Menu.JPG
Open_Menu.JPG (16.69 KiB) Viewed 607 times

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

Re: Object with two different xpaths concurrently?

Post by odklizec » Wed Oct 05, 2016 7:00 pm

Hi,

In this case, you need to define two separate repo items, one for each menu item. Or you can have just one with variable, which you can dynamically fill with the element name/id belonging to the menu item you want to interact with. Could you please post a Ranorex snapshot (not screenshot) of the problematic menu element? With snapshot we can suggest you best xpath.
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

npanag
Posts: 33
Joined: Thu Jun 02, 2016 5:42 pm

Re: Object with two different xpaths concurrently?

Post by npanag » Thu Oct 06, 2016 8:22 am

The problem with the snapshot is that it included sensitive corporate information and I was not permitted to create it. Is there a way for the snapshot to include only the structure of the application without the company data? I didn't find something.

The solution with the second repo item is, I think, a better solution. How do I do that? With Add New Item? What about Open from Disk or Embed Repository? My need is that the already well defined objects of Fund command in a separate solution to be imported as they are with their definitions in the current repository of Company solution. Because when I import a recording from Funds, their xPaths disappear and only the Company xPaths survive.

Is there a massive command to import all the Fund elements with their own xPaths to the Company repository and not creating one by one every element (I suppose with Add New Item)?

Thank you

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

Re: Object with two different xpaths concurrently?

Post by odklizec » Thu Oct 06, 2016 12:15 pm

Hi,

As for saving snaphsot without sensitive info in it, I'm afraid, the only thing you can try (aside manually edit the snapshot file) is to uncheck the option "let snapshot contain complete ancestor tree", which reduces the amount of saved data to just those belonging to selected element. See this post about details how to do this...
http://www.ranorex.com/forum/ranorex-fr ... tml#p37277

I would suggest to track the menu "Open" (its container), with all its items (query, contacts, companies, etc...)

As for adding new repo item, you can either create a new repo item or simply copy the existing one and just replace its xpath.

As for importing recordings between the solutions, it depends on your typical use. Sometimes, it's better to link repos, sometimes is better to embed them and sometimes is best to copy all repo items from old repo to new one :) I would suggest to try each option and decide what's best for you in a long term run. I'm afraid, I can't help you more here, because I'm working on a separate projects, with completely different repos ;)
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

npanag
Posts: 33
Joined: Thu Jun 02, 2016 5:42 pm

Re: Object with two different xpaths concurrently?

Post by npanag » Fri Oct 07, 2016 10:49 am

OK, thank you for your time and advice. The company finally accepted today the different scenarios approach e.g. one scenario for company, another for fund etc., so for now is OK. There is no need for any snapshot.

But the list of problems is still growing. I hesitated a bit, thinking if I must open a new post. Anyway, asking for your sympathy, this is the new problem:

I try to validate some boxes in the detailed form of a company comparing some values from an Excel file (bound variables). For a text box the attribute that contains the actual data is Value.

For a combo box which attribute do I compare with an Excel value? I would expect something like Text or Value, but there isn't something. You can see the attached picture.

Thank you
Attachments
Combobox_Attributes.JPG
Combobox_Attributes.JPG (85.35 KiB) Viewed 566 times

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

Re: Object with two different xpaths concurrently?

Post by odklizec » Fri Oct 07, 2016 11:09 am

Hi,

Usually, the combo box text is stored in InnerText or TagValue attribute. Have you examined the combo box in question with Ranorex Spy? This should give you an exact answer, which attribute should be used for validation.
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

npanag
Posts: 33
Joined: Thu Jun 02, 2016 5:42 pm

Re: Object with two different xpaths concurrently?

Post by npanag » Fri Oct 07, 2016 12:16 pm

Unfortunately innertext and the TagValue are not the case. They don't contain the value 'New York' that I want. No other attribute has 'New York'. 'New York' value exists in an Option below.
All the Options below are the items of the combo box. The Option that has the same TagValue as the TagValue of the select object above is what I want. It has innertext 'New York.' The name of the Option is like 'Option '5BE1AF02A...'

But I don't know how to get it.

It should be something like:

.../select/option[@value= or @innertext = something like ../select[@tagvalue] (meaning the tagvalue of the select object above
Attachments
ComboBoxValue1.JPG
ComboBoxValue1.JPG (39.92 KiB) Viewed 562 times

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

Re: Object with two different xpaths concurrently?

Post by odklizec » Fri Oct 07, 2016 12:51 pm

I see. The combo box alone contains only a 'radnom' number, which you need to match with an option inside the combo and only from there you can get the appropriate string (e.g. New York).

You need to create two repo items...
One for combo box alone, from which you need to read the 'cryptic' TagValue, for example by using GetValue action and store the result in a recording variable (e.g. $cmbTagValue).

Then second one for 'option' element, where xpath should contain the TagValue attribute which should be filled with previously obtained $cmbTagValue variable, e.g. something like this:
.//select/option[@tagvalue= $cmbTagValue]
Now you need to add another GetValue action, which should be applied to the second element and from which you can now get the InnerText with appropriate string. Hope this helps?
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

npanag
Posts: 33
Joined: Thu Jun 02, 2016 5:42 pm

Re: Object with two different xpaths concurrently?

Post by npanag » Fri Oct 07, 2016 2:07 pm

My congratulations. It worked exactly as you said. Taking the TagValue of the combo box in a variable, putting the variable in the definition of the option object below and validating the innertext of this option object.

The only problem that was raised is that one combo box doesn't have a value, so no option object exists below.
This raises an error that stops the iteration. I want Ranorex to continue just with the next command and not stop the current iteration.

It's similar with the error resume case in code:

On error resume next

Therefore I want the code to continue with the next command, and the small red pie to appear in the final green circle

How do I achieve that?