Dynamic Variable Inside Strict Selector Not Working (Finally Solved)


I have selectors that have two dynamic values that always change in the strict selector when editing a target. The first variable in the selector is only numerical which replaces an ID. Example: <web ctrl id='ctrl k (variable name is inserted)' />. This works fine.

However, for my second variable which is defined by a <web ctrl class='ctrl k (variable name is inserted)' />, this variable consists of alphanumerical characters. But even when both of those variables are replaced by the correct values through a random generator that does exist on the webpage, it simply does not execute the click activity. If I keep the latter variable to static, however, it does work.

So, this concludes that only numerical dynamic variables might work. I even tried removing the first variable’s value and keeping it to static, and the second one inserted the variable, but this still does not work. I don’t know what else to do because the activity is supposed to execute the task since both variables’ values are correct. Any help is much appreciated.

Hi @private_matter,
Please put * steric it means it will accept all the characters which is different Evey time.

I already placed an asterisk (*) character where the id changes, but that still doesn’t work. And even if I keep it as it is with the id, it does not locate the element though its correct. Might it be due to the System.String array?

Hi @private_matter Could share the screenshot of full selector here?

Update: I partially figured out what the issue was about. The randomClass int32 variable is being replaced by a number inside the strict selector which is why the activity is not executing since it has to be the string name. If I insert a message box before the click activity like this "Class is " + arraystr(randomClass), then the name will show definitely. So, I need to do the same inside the strict selector. I tried doing <web ctrl = '{{arraystr(randomClass)}}' />, however this does not work. And it gives me a warning icon. So, the question now is what format writing should I use in order to make it display the random string name instead of the int32 number?

Final Solution:

Variables List

arraystr (Type System.String[.]) has default value set to {“string1”, "string2, “string3”}.
randomClassInt (Type Int32) does not have any default value.
randomClassStr (Type String) does not have any default value.

Use Multiple Assign and add
randomClassInt = New Random().Next(arraystr.Length)
randomClassStr = arraystr(randomClassInt)

This will convert the generated numbers to names instead.

In strict selectors, I replaced the dynamic variable names by hitting Ctrl K and selecting randomClassStr from the dropdown. Make sure to replace any dynamic values with a wildcard asterisk (*). Hope this helps anybody looking for a similar solution. :slightly_smiling_face:

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