Using a Variable value as a clicking selector?

Hi there,

I am trying to make it so that a variable that I am using is what the bot is able to read as part of the selector.
A quote number displayed in a table on a website links to the customer page when clicked. I’ve established that the bot can read the innertext of this and so I want to set the variable (pQuoteNumber) as a variable value as it will change each run.

image

I think I might have written this incorrectly, but can’t seem to get the right format; it just failed as a selector issue. Could anyone please tell me how the innertext section should look?

Blue lines are redacted customer info just FYI. Thank you!

Hi there @dr1992,
I hope you are well!

If you right-click where you want your Variable/Argument to appear, you should have the option to insert it - The formatting will end up as:
<webctrl tableCol='4' tag='TD' innertext='{{pQuoteNumber}}' />

Hope that makes sense - Please let me know if you have any questions.
Thanks in advance,
Josh

@dr1992

It should be like below.

        innerText = '"+pQuoteNumber+"'

I tried this before, but sadly it doesn’t work :frowning:

Hmm this did not seem to work either (cool tip about the right click though, thanks).

If it didn’t work then you didn’t do it correctly. It works fine, if done correctly.

Go into your selector, highlight where you want your variable, right click and select your variable, etc.

Then show us your result.

And then the same but ‘“+pQuoteNumber+”’ instead of curly brackets.

I tried both suggestions above and received a ‘Could not find UI element’ error both times. Not really sure what you want from me.

If your title is changing each time try removing title as a required part of the selector, or try simply replacing everything between the single quotes with an asterisk ie: title=‘*’/>

For you to show us your entire selector. Also, show us the selector you get when you use Ui Explorer and indicate the element.

Hi again @dr1992,
Hmmmm, does your Variable/Argument have a Default Value?

You will receive an element could not be found, if that is left blank - While validating in isolation.
Maybe worth setting it, if you have not already.

Otherwise, as @postwick noted above, you will need to show us the regular Selector, so we can help to troubleshoot.

Thanks once again,
Josh

@dr1992

If you write quote number directly instead of passing variable then is it showing valid selector ?

If yes then above should work. And also hope you passed value to the variable before selecting the element. Can you please share the screenshot of the error message.

Hello @dr1992 ,

If you have already declared the variable and if it is having some values before using it in the selector. What you can do is , remove the portion the selector you want to replace with the variable and right click on the position which you removed and select the variable .

It will work in the latest designer.

Thanks Josh; the pQuoteNumber is read from a JSON file, so it gets called upon as an object (which is pulling through).

I think that the issue might be that the innertext selector has white spaces afterwads, so like ‘123456/1WHITE SPACE’, is there a way I can use the {{pQuoteNumber}} to remove white space from the end?

Thanks a lot.

@dr1992

  • Remove the data in selector between single quotes, right click and you can see choose variable option and select which variable you want to insert. After variable don’t include any *

  • Before you pass the variable to this selector or after reading from a JSON take assign activity

 pQuoteNumber = pQuoteNumber.Trim
  • Also, just to check the selector is working go to the variable in the variables panel, and provide the default values(you can remove it later) as 123456/1

  • Now go to your selector and validate it

This worked once I put an * to clear the white space. Appreciate your help!

1 Like

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