Issues with Dynamic Slector on Click activity

Hi Everyone,

I am using the click activity to click on various option in the drop down list by fetching values from the excel sheet using while loop. But I am getting the below error message.

“The selector is not valid”
Exception Type: uiPath.Core.InvalidSelectorException

I have followed the below method.

Assigned as below
varSelect=BranchDetails.Rows(rowNumber)(“Select Brand”).ToString
selectorContent=""

And in the click activity, I have used the variable selectorContent.

The value is getting fetched and getting the selector not valid error. I also have tried using the Expression Editor like suggested in other posts. But still getting the same error. Would really appreciate if someone could help me to understand where the issue is.

Note: If i pass the direct value the varSelect, it does work.

Thanks!

Before doing the click actvity use attach browser activity , attach the browser where you want to click, then inside that use the click activity…

if the variable selectorContent which used in selector is blank then selector will be invalid. you have to pass some value or you can use * for making it dynamic.

check the selector is valid or not in UIexplorer.

I’m unable to understand why you need selectorContent if it is working with VarSelect

If you want to click inside the dropdown box then use UI-Explorer(Visual Tree) for the proper selectors…

Hi Sreelatha, sorry that i have missed the bit what i have mentioned in the selectorContent. Below is the one.
selectorContent=""

Hi @Vijithav,

Can you show the selector string values?

1 Like

Selector contents are empty???..
Use the selectors like aaname,tag,parentid for your click activity and assign it to SelectorContent…

Sorry, when i pasted it, below has been missed

selectorContent="<webctrl aaname=’ “& varSelect &” ’ parentid=‘data.brand_id’
tag=‘SPAN’/ >"

1 Like

Hi Manish, tried using the attach browser activity, but still the same error.

Whether the aanames which are in the excel are same as in the dropdown list???..A
And do varSelect.Trim in the selector…

Yes, the aanames are the same as that of the dropdown.
Instead of passing the entire selector as a variable, i tried the giving the below syntax in the selector of the click activity. But still doesnt work. Is the below syntax correct for passing the variable varSelect?

“<webctrl aaname=’ “& varSelect &” ’ parentid=‘data.brand_id’
tag=‘SPAN’ / >”

try this one

“<webctrl aaname=’ “+ varSelect +” ’ parentid=‘data.brand_id’
tag=‘SPAN’ / >”

I think I figured out where the problem could be.
Looks like the first value (Ben’s Cafe) in the excel has a special character. To test, i assigned the rowNumber to 1 and it works as the rest of the values in the excel are just strings. So I think the problem is with the “variable type”. I tried declaring my variable varSelect both as “string” and “GenericValue”. But looks like am missing something as it still doesnt work. Any thoughts?

varSelect=BranchDetails.Rows(rowNumber)(“Select Brand”).ToString
selector = “<webctrl aaname=’ “& varSelect.ToString &” ’ parentid=‘data.brand_id’
tag=‘SPAN’ / >”

@Manish, thank you so much for your suggestion to look into the aanames which helped me to narrow down the issue.
@Sreelatha, thank you so much for teaching me another syntax and trying to help me out.
@kuppu_sami, thank for your time in trying to help me out.
Looks like i had to use regular expression to fix the issue of getting the “selctor not valid” issue as the drop down had values with the special character “’”.
“<webctrl aaname=’ “& varSelect.ToString.Replace(”’”,"*") &" ’ parentid=‘data.brand_id’ tag=‘SPAN’ />"

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.