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!
You can set your selector to replace if below contains. Also you can also test using a wildcard.
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?
How can we use this escape ?
Thank you. I am using Modern Design Experience (Studio).
Thank you for these examples, but still not advised as to how to adjust selector to account for these scenarios. Please advise. Thanks
When I use your method, I’m receiving innertext=‘Father's Day’
It’s adding the & within my selector. I have my Variable as
I have also tried.
Each time I get same output which is error because it’s looking for ‘Father's Day’ and not ‘Father's Day’
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:
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
It is now possible to use Regular Expressions in your selectors. Follow this guide to learn how!
We have added extra syntax to the Selector Editor to allow for advanced configuration of your selectors.
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
My issue is how to apply this to random value in a variable.
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.
Ahh. I see. Makes sense. I’ll need to spend more time on Regex. Should I provide the selector?