alvini
(Alvin)
June 20, 2022, 9:12pm
1
Hi UiPathers!
My bot ran into an error while going to click a selector. The error message provided is “The selector is not valid”.
When I went to check the value in question it was listed as “Father’s Day Gift Ideas”.
I tried to validate the selector and found the single quote in “Father’s” was the culprit. The string was passed through a variable(string). My question is: How can I adjust my selector to account for scenarios, where a random value within a variable such as this, is encountered with a single quote or any other chars that disrupts the automation?
I’ve attached a screenshot of my selector. Thank you!
Hi @alvini ,
You can set your selector to replace if below contains. Also you can also test using a wildcard.
Regards,
MY
2 Likes
Hi @alvini
Further to @muhammedyuzuak ’s post.
You should clean your string first with escaped characters.
Check out these links:
Library Link #1
Library Link #2
String.Replace Method should assist.
Are you using StudioX?
Cheers
Steve
2 Likes
How can we use this escape ?
alvini
(Alvin)
June 21, 2022, 6:23pm
6
Thank you. I am using Modern Design Experience (Studio).
alvini
(Alvin)
June 21, 2022, 6:54pm
8
Thank you for these examples, but still not advised as to how to adjust selector to account for these scenarios. Please advise. Thanks
alvini
(Alvin)
June 21, 2022, 7:36pm
9
When I use your method, I’m receiving innertext=‘Father's Day’
It’s adding the & within my selector. I have my Variable as
strArticleTitle=“Father’s Day”.Replace(“'”,“'”)
I have also tried.
strArticleTitle=“Father’s Day”.Replace(Chr(39),“'”)
Each time I get same output which is error because it’s looking for ‘Father's Day’ and not ‘Father's Day’
Hey @alvini
alvini:
My question is: How can I adjust my selector to account for scenarios, where a random value within a variable such as this, is encountered with a single quote or any other chars that disrupts the automation?
To answer your Question: Regex or the other above methods (escaped values / ASCII characters) should work with random/difficult values. Depends on the need really.
So, a fresh approach, lets try Regex in your selector.
I have made a quick Regex pattern which will allow for any single character between the R and S in “Father’s” - take a look and test to see if that suits your needs.
Replace this selector:
With this:
innertext=‘Father(.)?s Day Gift Ideas’ matching:innertext=‘regex’
If done correctly, the elements should update with colour changes. Something like the below:
Example from Tutorial
Tutorial Post:
It is now possible to use Regular Expressions in your selectors. Follow this guide to learn how!
What’s new?
We have added extra syntax to the Selector Editor to allow for advanced configuration of your selectors.
Let’s begin
As an example, I will be creating a selector that will be able to open a file whose name is dynamically changing.
Let’s assume I am receiving daily list of bills via email which are saved as a text file named ‘bills mmddyy.txt’, e.g ‘’bills 101019’. Now, I want to writ…
Hopefully this helps
Cheers
Steve
alvini
(Alvin)
July 6, 2022, 4:26am
11
My issue is how to apply this to random value in a variable.
Hi @alvini
When this issue fails, can you obtain the selector so it can be logged.
Once we have a pattern we can build a robust Regex Pattern to handle all scenarios.
Hopefully this makes sense.
Cheers
Steve
alvini
(Alvin)
July 13, 2022, 8:27pm
13
Ahh. I see. Makes sense. I’ll need to spend more time on Regex. Should I provide the selector?
Hey
Provide whatever you can.
You can learn Regex through my MegaPost.
Cheers
Steve