To ensure special characters are correctly interpreted in selectors, remember to escape them from the variable before using them. Here are some examples of html special characters: &,",',<,>
Try to use this method, it should escape every special character and after that you can use your variable in selector:
Yes, when I posted I tried to show & had become “& amp; amp;” in the dynamic selector value which then fails to match. I had encoded the & character to stop the Dynamic Selector error and get XML substitution by Robot to work.
It seems the value that is being used in the web page is not getting encoded by the Robot but the dynamic selector process that uses XML in the string.Format (blah blah, variable) is encoded. This results in a mis-match.
The error shows as “Could not find the user-interface (UI) element for this action”.
1)It looks like you’re trying to pass a character “&” as a dynamic selector. And yes, the studio generates a selector as &. For each special character mostly, studio creates a different one than the actual one
2)So, when you’re trying to pass “&” into the selector, make sure you change it to & and then pass. May be you can maintain these special characters in a config with the below format
Ex: First Column | Second Column
& | &
3)Before you pass any value as a dynamic selector, refer to the config file. If any special character found in the value, make sure replaces with the respective value. If you come across any other special characters in the future you can easily add to the config, without any code change in your project
Hi,
Thanks for the response.
Yes, I can make an explicit match on any individual selector value but it needs to be dynamic as the process is navigating a folder structure with circa 10,000 entries.
I have already tried encoding the & character as & but that still gives a failure. That is for the aaname not the innertext.
Yes, I appreciate that a config file could be used for the mapping. I could equally store the values in strings as assets in Orchestrator. The way to do the substitution is not the issue.
The issue is getting dynamic selectors to work reliably when the & character needs to be matched.
@DavidMartin - My uderstanding was, you’re passing a value with “&” inside the selector (dynamic selector). If this is the case, I guess one of the option would be, replacing the “&” with character(&)amp; before actually passing into the selector. This is also one of the reliable way as everytime you’ll be checking the value has a special character or no. To validate, take IF condition
Value.contains("&")
>> True then take assign activity
Value = Value.Replace("&","&")
>> Else Nothing
This is the input and how I formatted selector and it is working as expected and clicking on it string.Format("<webctrl tag='A' aaname='{0}' />", str.REPLACE("&","&"))
Instead of encoding the ampersand as “&”, try using the HTML encoding “&”. This should ensure that the selector is properly interpreted and matches the desired elements containing the ampersand character.
If the above solutions don’t work, you can try escaping the ampersand character by using double ampersands (“&&”) in the selector. This can help bypass the encoding and ensure that the selector is correctly interpreted.
In both cases the & character has been replaced. I have used * to get around the encoding issue, the best results are using ? as it is only a single character widlcard so the accuracy of the rest of the match is better.
Thanks. That is effectively the code I already have in place.
The only difference being your selector is using aaname, whereas I have the selectot using aaname and check:innerText
aaname most or almost always is same with innertext…from the script side there is no control on aaname field…its an auto generated…
Its not bad to give both…but as they are same it is not helping explicitly in identifying in anyway…so it is more redundant
And I believe Replacing & has been working…if not would really be happy to check what is different in the site you are using as it has been working that way. And that is the same reason I asked for a selector containing the actual aaname or innettext instead of the formatted selector after adding dynamic variables