Why can't we pass variables in CV text?

Hello,

I have a list of ELSEIF conditions that have country names. However, the element name of the country cannot be selected with fuzzy or strict selection. It can only be identified with computer vision text. However, the issue is that I cannot pass a string variable into that field as it does not support it. Thus, I’m forced to have around 100 ELSEIF conditions for every country. My technical question is why isn’t that possible to pass variables? Thx.

Hi @private_matter

Passing variables to selectors using computer vision is not supported because when using computer vision, the selector is generated dynamically based on the current state of the application, and the text values of the element being identified are used to generate the selector. Since variables can change at runtime, passing them to selectors using computer vision would require constant updating of the selector, which can be unreliable and inefficient.

To avoid ElseIf ladder, you can consider the this approach to store the country names in a data table or an array and then using a loop to iterate through them.

Hope this helps,
Best Regards.

@private_matter

Did you try pasing variables…I fee we can variablize it…we can send the descriptor as a string and that string can contain variables

Can you please try the same

Target: Icon (234,179,17,09)” + “Anchor: Text “+”'”+name+“'”+" (1334,158,17,15)"

Cheers

Thanks for the explanation @arjunshenoy
I know that I can easily use one IF instead of many to iterate using a variable but I’m unable to do so due to the CV. That means if the random string generated was picked as let’s say ‘United States’, then in the CV text field, I cannot set the same variable which will automatically be ‘United States’ as well. Thus, I’m forced to separate each condition by itself.

From where do those numbers come from? Can you explain a bit more because the icon is just an image when selected. There is nothing else.

@private_matter

I beleive you are taking about cv activities …if you open the descriptor of the cv activitiy after identifying you would see a string of this sort…which includes some coordinates and the name …we can variablize the name as needed

Cheers