Help with selecting fields now they are using a guid rather than a static value

Hi all,

I wonder if you could help. I have been using Recorder to populate a web form with data from a CSV. The developers have changed the table box values and instead of being fixed ID’s such as the below

xpath=//table[@id=‘myTable’]/tbody/tr/td[5]/select
xpath=//table[@id=‘myTable’]/tbody/tr/td[6]/select

each of the boxes is now prefixed with an id for each user in the table, such as the below

id=option1_%guid%

The guid is listed against other static values in the table such as the membership ID but how can I get Record to select that box without providing the guid. I should say that I filter the table my membership ID so there is only one result, and the previous method worked perfectly until the field ID’s have now been changed to include the guid for each user.

Can I reference the first line in the table in any other way without needing the guid?

Thanks in advance!

I have been playing around with this a bit and might have made a little bit of progress… but still could do with some help…

So the actually id of one of the fields when chosen using the selector is id=contact_%guid% so this works when populated into the target field, however if I try to use starts with, as that should work for each contact then, I get a problem.

xpath=//id[starts-with(@id,‘contact_’)]

Any ideas?

Thanks!

The issue is that <id> is not a tag; it is an attribute. If we use your example, you can use either:

This can only be used in this manner with the <id> attribute.
xpath = id("contact_xxxx")
but this does not seem to work if you use a function like contains() or starts-with().

This is the normal way to do any attribute. Since I don’t know what your actual tag is, I just used the “wild card”; asterisk. If the actual tag is an “input”, then you can replace the asterisk with the phrase, input
xpath = //*[starts-with(@id, "contact_")]

or

xpath = //*[contains(@id, "contact_")]

Additionally, you can use a second attribute, like “name” to uniquely qualify a pathway:

xpath = //*[contains(@id, "contact_") and @name="BigBoy_ContactInformation"]

Edit: You should note that if your pathway is not unique because you used “starts-with” or “contains” and not the rest of the id, then you will have to use another reference to make the pathway unique. You would be careful to “test” your pathway within your HTML using DevTools (starting with the F12 key and then CTRL + F) to ensure it returned a unique pathway giving you on the right side a display of “1 of 1” and not something else or worse, nothing.

image :slight_smile:

image // Grrrr

1 Like

Thank you! That’s is now working :slight_smile: :grinning:

One question when you say you aren’t sure what the tag is so you have used the wild card * - how can I identify what the tag is?

Thanks once again!

I am curious how you got the pathway you are using if you don’t know the specific tag at the front of the <id> attribute. I review the HTML when I am building pathways to my objects. Below I have highlighted a <p> tag that is associated with your text in the post above, differing from all the <div> tags above it.

image

Edit: To start DevTools to review your HTML, either hit the F12 key, then use either CTRL + SHIFT + C or the first icon within DevTools that looks like a rectangle with a pointer moving into it. Then move your mouse pointer to an element. Click on the element to have the HTML move to that element. Or you can hover over the element to have the information displayed.
If your application supports it, you can right click on an element and choose, Inspect. Then choose Inspect again to move the HTML right to your element.

It’s possible the recorder itself picked up the change, but it wouldn’t work OOTB like so. But yeah, wildcards are riskier than using an actual HTML tag to match it with.

XPaths (and selectors) should typically be as abstracted as possible, but as specific as necessary :grin: