Cannot edit a portion of the path in Editor Path (Edit iSpy)

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

Cannot edit a portion of the path in Editor Path (Edit iSpy)

Post by npanag » Fri Sep 16, 2016 9:27 am

Hi,
I try to build a scenario in a heavy web application. My problem is in identifying some objects in the web forms. For example, i record some actions in Ranorex and for one combo box in a web form, it gives me:

/dom[@domain='frontinvesttest:8080']//td[#'framescontainer']/div[5]//table/tbody
/tr[2]//div[@id='id_controls_area']/div[14]/div[4]/select

Running this in Ranorex gives an error (not found), so i tried to amend it.

I tracked the same combo box in the independent Spy and it gives me:


/dom[@domain='frontinvesttest:8080']//td[#'framescontainer']/div[6]//table/tbody/tr[2]/td/table/
tbody/tr[2]//div[@id='id_controls_area']/div[14]/div[4]/select

There is already a difference in the first div (div[5] and div[6]). I worked in external Spy and found this path to be working:


/dom[@domain='frontinvesttest:8080']//td[#'framescontainer']/div//table/tbody/tr/td/table/tbody
/tr//div[@id='id_controls_area']/div//div[@ajxname='RT_COUNTRY1_2']/select

I tried to avoid relative addresses as per a video of yours that suggested only tr or td without numbers and i found in Internet Explorer (with F12) the ajxname that was not visible in Spy.

My problem is that I cannot edit the full path of the recorded action. I click Edit in the object in Repository and the first part with div[5] is grayed and not editable.

You can see the grayed part in the attached jpg I've sent you.

Do you know how to edit the specific object? Alternatively, can i create a new instance of the object with the correct reference?

Thank you

Nick
Attachments
Editor_Path.JPG
Editor_Path.JPG (37.97 KiB) Viewed 580 times

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

Re: Cannot edit a portion of the path in Editor Path (Edit iSpy)

Post by odklizec » Fri Sep 16, 2016 10:03 am

Hi,

The reason why you cannot edit the grayed-out part of the xpath is that it belongs to a parent (rooted) folder. In other words, if you want to edit the 'disabled' part of xpath, you need to go to the parent repo folder, in which is placed your problematic element.

Generally speaking, using element indexes in the xpaths makes them prone to failure, because indexes are not persistent. They should be used only as a very last resort, if there is absolutely no other way to identify an element. Ranorex recorder tries to find the best xpath, but if there are no unique IDs, it often picks element indexes. So after each recording session, it's recommended to go through all recorded xpaths and eventually modify them, to make the xpaths more reliable. Good luck!

BTW, could you please upload a Ranorex snapshot (not screenshot) of the problematic element, so we can review the entire GUI structure and eventually suggest a better (indexes-free) xpath. Additionally, please check the recent xpath-related blog post, which can give you some tips about identifying elements via related elements:
http://www.ranorex.com/blog/ranorexpath ... nd-tricks/
And also this one, about automating elements with dynamic IDs:
http://www.ranorex.com/blog/automated-t ... namic-ids/
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: Cannot edit a portion of the path in Editor Path (Edit iSpy)

Post by npanag » Wed Sep 21, 2016 10:35 am

Yes, you were correct. The objects belonged to a folder named SomeTableFlag. I changed there the div[5] to div.
I spent some days reading the material you mentioned and finally I was able to find a solution using XPath expressions that match a dynamic id.
Thanks a lot.

By the way, I didn't sent a snapshot file because it included some sensitive company data and I could not proceed.

Something other now:
I don't know if I must open a new post... Anyway, I have the following question:
Sometimes, occasionally, my web app under testing, after a close of a specific tab gives a message box: "Are you sure you want to close folder? If you confirm, all modifications since last save will be lost" and has an OK and Cancel button:

/form[@title='Message from webpage']
/form[@title='Message from webpage']/button[@text='OK']
/form[@title='Message from webpage']/button[@text='Cancel']

How can i say that if the message box exists click OK?

I assume some user code like:

if ("message box".exists)
{

/form[@title='Message from webpage']/button[@text='OK'].Click
}


Could you help me? I suppose that inside Ranorex we don't have an if structure to cover this issue.

Thank you in advance

Nick

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

Re: Cannot edit a portion of the path in Editor Path (Edit iSpy)

Post by odklizec » Wed Sep 21, 2016 11:41 am

Hi,

Of course, conditional statements are possible in Ranorex, just not in the recording table. You will simply have to create a "user code" to perform conditional statements.

From the description of your problem, the appearance of message box seems to be random? In this case, you can use Ranorex PopupWatcher method, as described here:
http://www.ranorex.com/support/user-gui ... html#c4678
Once implemented, it will "watch" the appearance of given element and do whatever you specify it to do (e.g. click the button to confirm/dismiss the dialog).

On the other hand, if the appearance of message box is predictable (as a result of certain steps), it's better to use recording/code module following the steps that invoke the message box and simply close the dialog via this module.

BTW, your tests should be consistent and there should be nothing like "random" dialogs appearing here or there! If the test is properly designed, the message dialog should either be always present or always not present (after performing exactly the same steps multiple times).

I'm personally using popup watcher mainly for debug purposes, eventually for watching/closing some system-related "dialogs", which could break my tests, but which are unrelated to my tests. I would not recommend to use the popupwatcher as a main tool for capturing dialogs/elements invoked by test steps.
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: Cannot edit a portion of the path in Editor Path (Edit iSpy)

Post by npanag » Wed Sep 21, 2016 5:08 pm

To tell the truth, it's a strange behavior.

When i say Run suite test and i leave it, then it finishes successfully with no problem.

When I bring the running command box in the front and I put it side by side with the web app, then, after a successful iteration of 3 companies, while I'm just running 5 Validate commands (about existing of some text boxes and combo boxes in IE), then the web app wrongly assumes that something changed in the detail form of a company and then while closing it it shows the dialog box about loosing the changes and OK or Cancel.

I don't know what exactly is this. But your eager answers prompt me to ask you some questions:

1. Where do we put the watcher code? In the program.cs for initialization? And then if the dialog box really exists we put the click OK command to the user code.cs? Sorry for the naive questions, but I'm new, not only to Ranorex but also to c#.

2. There was an initial small window that showed with a progress bar the Delay commands in the test. After changing the properties of the recording to "Continue with iteration" it started showing the small "Dos" window with the Validate commands in green. Can I show again the initial window, or you believe this "Dos" window is better and more practical?

Thank you for your understanding

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

Re: Cannot edit a portion of the path in Editor Path (Edit iSpy)

Post by krstcs » Wed Sep 21, 2016 5:24 pm

Both the DOS Console AND the Ranorex Progress Dialog should be displayed for your tests. The only exception is if the Test Suite's settings were changed to NOT show the Progress Dialog. You can change it by right-clicking the Test Suite's top row in the Test Case view and selecting Properties. The checkbox for "Show Progress Dialog" (or something like that) is at the bottom of the dialog.


One note: You should not be interacting with the desktop or any other apps while your test is running on the same system. This can cause all sorts of issues with the test because Ranorex assumes that it has control over the mouse and keyboard and that it will know exactly where focus and the cursor are at all times.

As for where to put the watcher code, yes, you can put it in Program.cs, but I actually create a module for each watcher and put that module in the test suite's Setup section (right click the suite and select Show Setup/Teardown). This will force the module to run and start the watcher each time the test is run.
Shortcuts usually aren't...

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

Re: Cannot edit a portion of the path in Editor Path (Edit iSpy)

Post by npanag » Wed Sep 21, 2016 7:36 pm

Thanks a lot for the info