I need a way to be able to use matching regex within a selector I have.
Currently in my automation, please view the "WA2" in the screenshot:
This "WA2" changes depending on the activity I’m trying to select, and I’ve identified that the variation will be WA then one of 0,1,2.
Unfortunately, the classic ? wildcard is not working for me in this case (nor does *):
So I immediately thought that we can use the regex build WA[0-2]* to be able to identify this selector rather then try to make a bunch of different combinations (This appears for a total of 3 times, so it’s not reasonable to create all the different variations).
That’s where I need help. I’m not sure how to actually construct the RegEx within the selector.
I tried following the documentation , and got this result:
Here are some other attempts of trying things from the documentation link:
Another idea I have is to make the actual [0-2]* regex pattern as a variable then concatenate this into my selector. But I cannot figure out how to only have this value. The closest I could find was using System.Text.RegularExpressions.Regex.Match("WA?","[0-2]*").Value which is correct syntax, but this does not work in the selector! I can’t say in advanced what the string I’m modifying is so I need that wildcard.
As of now i can see that Within the selector you have “WA” stable always if i am not wrong.
And only the further number is changing frequently which is of single digit Right ?
So ? is a wild card that takes only single value and you too needs the same.
It’s just really strange to me. The selector is very picky on it only being WA2, but when using this selector on a different web page but an otherwise similar HTML/Selector setup, this selector can change to WA0 or WA1, which will complain the exact same way. I don’t understand why a simple ? would get rejected if the ? is already checking every possible match to make the selector work. Maybe that’s not the case, and this specific selector must see that 0,1, or 2 otherwise it rejects. @Pratik_Wavhal
From the screenshot you posted it appears there is another webctrl id named ‘WA1’ with the same tag ‘IFRAME’ as well as a ‘WA0’. Try changing those as well and in other times is appears in the selector.
Thanks for replying. I tried your suggestion, this doesn’t seem to work either. It seems either I cannot figure out the right syntax here, or the documentation I listed above doesn’t work. It’s most likely the former.
Thanks for getting back to me. I apologize for not being more clear. No this does not work, I was trying to make the problem more obvious by isolating a single selector, but yeah it doesn’t work when I put all of them with ?. To be clear, none of the ? or * combinations seem to work. I need to use a more specific pattern matching solution and the only thing I can think of is using a regex pattern beyond these wildcards.
The next step I would try is using the UIExplorer tool and selecting that element. From there you could possibly find other aspects of the selector to include or un-include that would make it valid.
@rmckinnon
Is this site accessible to us? (I’m assuming it’s not, but thought I’d ask)
The wildcard * or ? should work, so my first thought is the IFRAME71, DIV14, and STR25 is causing it to not validate. I would suggest trying to remove all but the first few lines with highlight on, to see if it validates and what it is looking at. Then, try adding some lines back in til it stops validating.
I don’t think regex is really needed in this case.
IFRAME71 can be omitted,
omitting DIV14 still gives a Validated selector, but removes the highlight.
omitting STR25 still gives a Validated selector, but targets a different component. (this one is responsible for going down the list of checkboxes)
In this screenshot my goal is to be able to identify the highlighted box, with the minimum selector code necessary to recognize this:
The issue is the WA2 and WA1 don’t Validate when I try replacing the number with a ? or *. I can’t hardcode these selectors because similiar to the screenshot above, I need to perform this activity of identifying the checkbox, but with a different “ServiceName”. Note how the title was mdmCustomerCompositeVS , and see when I try a different Service Name and again try to minimize the selectors needed below:
I’m not sure how else to explain it, but pretty much depending on what I deploy there exists at least one of these WA# tags that break if I try using a selector. I also attached a video in hopes this can showcase my issue more.
Are you wanting to check the box for every row, just the first row, or a specific row based on certain text in that row? There might be other approaches to the selector depending on what you want to check.
I’m assuming you are using the Check activity, which is my suggestion, unless it doesn’t let you. Click would also work, but just doesn’t work as well.
So my suggestion to resolve the selector would be play around with inside the UiExplorer. This way you can see all the attributes: tableRow, tableColumn, name, id, etc
The idx attribute is not good to use. I’m wondering if that’s why it’s unable to validate when you wildcard it.
But changing that out with the tableColumn is a good way to not use the idx. Also, the tableRow can be used to select the first row, or even replace the value with a counter variable.
Also, using UiExplorer, you can see all the values in the rows (usually), so you can make an even easier selector, if for example you want to look for “Deployed” or something. Then, you might ‘not’ even need the WA? part.
If you show what UiExplorer shows as far as attributes, I can help further.