How can I record a generic xpath without the machine name

Best practices, code snippets for common functionality, examples, and guidelines.
fester13579
Posts: 30
Joined: Thu Feb 13, 2014 9:29 pm

How can I record a generic xpath without the machine name

Post by fester13579 » Wed Aug 24, 2016 3:26 pm

I am currently building my 1st WEB based test cases on “MachineA” but will later run this on “MachineB,C,D...”.

While building my recordings, each click is recording the full path of A in every xpath and I then have to edit every single one to use a regex match on a substring so that it will still match when running on B.

Is there a way to make the recorder not be so literal and thereby save me the re-editing time on all my clicks.

I thought perhaps this would help but apparently it does not
The unique ID search can be enabled/disabled within the “General settings” -> 'Enable search by unique ID (if available)'. “

Thanks...
foo2.png
You do not have the required permissions to view the files attached to this post.

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

Re: How can I record a generic xpath without the machine name

Post by Support Team » Thu Aug 25, 2016 12:55 pm

Hi fester13579,

I would suggest trying to work around this issue as follows.
  • Track the IFrame element with Ranorex Spy and add it to the repository
    add_to_repository.png
  • Convert the item to a rooted folder
    convert_to_rooted_folder.png
  • Edit the path for the rooted folder via the Path Editor and apply the regular expression
  • As a consequence, new recorded or tracked items will be located within this rooted folder and you won't need to adjust the regular expression again and again
    repository_result.png
Alternatively, you could try creating a RanoreXPath Weight Rule that prefers a different attribute when generating the path (assuming that there is a different attribute that could be used for identifying the IFrame).

If you need more information please do let me know.

Sincerely,
Johannes
You do not have the required permissions to view the files attached to this post.
.
Image

fester13579
Posts: 30
Joined: Thu Feb 13, 2014 9:29 pm

Re: How can I record a generic xpath without the machine name

Post by fester13579 » Fri Aug 26, 2016 2:21 pm

Thank you...