I have created a web app automation project which contains many ‘click’ and ‘type into’ activities. and almost every activity’s selector contains title attribute. which may vary while moving that project into production environment. so i planned to set a string variable instead of static title value and implemented that as follows.
< h t m l t i t l e= ‘"+varName+"’ / >
(without the spaces in html title)
but its not working. Anyone please help me to solve this problem.
(fyi , you can use “\” infront and it will show the < without the spaces)
Please output the entire string in Message Box or Write Line to verify the selector is correct and matches what it would say with UiExplorer etc.
Then, you can use that string in the selector text box in properties.
Should be like this:
"<html title=’"+varName+"’ />"
including the outer quotations.
Thanks Clayton. I will try and let you know if its working or not.
After modifying the selector, use it by dragging a new activity and paste the selector in selector region of properties.
Don’t indicate the element on screen.
@ClaytonM How do we handle if the variable varName has special characters like ( ’ , " )
I would probably use a Regex pattern, like this one
Then, you can use .Match or .Replace
Regex.Replace(str, pattern, "")
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
You can now define your variables for selectors directly in Studio.
Please check our official documentation here:
A dynamic selector uses a variable or an argument as a property for the attribute of your target tag. This allows the selector to easily identify a target element based on the value of the variable or argument, and not an exact string, which might...
As well as this short tutorial on our Forum:
This tutorial will teach you how to easily use variables in your selectors. In other words, we will be making dynamic selectors without the use of the old method of concatenating strings. How cool is that!
For the purpose of this tutorial, I will make 1 click in the Notepad app.
Feel free to also reference our documentation here.
1. First, we will indicate the element we want to click on. In this case, it will be File menu in Notepad:
This results in the…
I took the liberty to change the solution flag to this post to let our users know about this feature
Old solution post is . this one