Any way to use a wildcard in a selector for up to 2 characters?

Hey guys, I have a very complex selector where in the middle it can occur that there’s one or 2 extra characters. Now I want the activity to be able to handle this, but I can’t just use an asterisk, as that can bring wrong results when there’s a whole lot more characters in the middle. So I was wondering if there’s any way to use wildcards it such a way that it can handle 0 to 2 characters?

For example, one the tags in my selector right now is the following:
innertext=' 		 		 		 	 		 		 		 		"+question+" *Ja*'

But it can occur that there’s an extra part, like this:
innertext=' 		 		 		 	 		 		2a 		 		"+question+" *Ja*'

I’ve tried just using an asterisk, but that makes it select the wrong element as it picks one where there’s a ton of extra characters on the spot of the asterisk.

Curious to see if anyone knows a solution. I’d like to avoid using try catch blocks with several ?? wildcards in it :slight_smile:

? can be used for single character replacement, see if it solves your purpose :slight_smile:

1 Like

@Sheshrocks, thanks for your response. I know that, but in this case it can be anything between 0 and 2 characters. So just using a ? won’t work, because it won’t be able to find the cases when there’s no extra character.

can you tell what is the element you trying to select, is it from any web page or application ? may be i can try and then tell.

Some time need to think out of the box!

Hi @evangemert,

can you try extracting the attribute using get attributes (like you have inner text )and then pass that into the selector using a variable
Then pass that selector to your ui element to perform that specific action

I hope this helps!

Regards
Srish

It is basically a questionnaire on a webpage, which can vary a lot. I extract the questions it needs to find from a config file. The robot needs to be able to handle a lot of different questionnaires. Now on some questionnaires, there’s a question number in the innertext element, while on others there isn’t. It is always on the same spot and will be a maximum of 2 characters (e.g. question 9a).

Right now I have found a way to handle it, using a Do While block and adding a ‘wildcard’ variable in the selector, which starts empty and on the next cycle adds one ?, and then another ?. If it hasn’t found the question after that, it throws an error. Seems to work for now, but it’s such an ugly solution :slight_smile:

If it is in the same spot then try anchor base selector, where you can mention an image or an element as anchor, would that help ?

I’m sorry, I meant it’s always on the same spot inside the innertext element of the selector, not on the screen.

Can you share the link to that web-page?

I’m afraid I can’t, it’s an internal system, though web-based…

Any other sample? Want to visualize to derive a solution.

I don’t think I can share anything, due to secrecy policies of my client and all that… So for now I think I’m just gonna stick to the solution I mentioned earlier, however thank you so much for your time and ideas!

2 Likes