Variable in selector

Good Morning,

I want to put a variable in my selector so that it will click on the element with that specific variable name instead of the same one everytime. However, when I do it, I keep getting an error and it is not clicking anywhere. Does anyone have a solution for this?

1 Like

kindly have a view on this thread

Cheerss @amb13

2 Likes

@Palaniyappan
I tried this but When I validate it, it does not turn green. Not sure why this is not working

if possible can i have a view on the selector with a screenshot
Cheers @amb13

  1. Take both the selectors and check what is differing in both of them.
  2. Then, Make sure you are not passing the variable in the selector directly. Pass the selector as a string variable again. I mean, just assign the selector to a string, then replace the differing value as a string again in the variable and then pass this variable to the selector so that it will work.

Can you try this way and let me know if you have any issues @amb13

@Palaniyappan
Yes,
I want the aaname=In_FileName beacuase I want it to click on the file with the name that is stored in the variable each time, but it does not want to do that.

Hi @amb13

Does the variable have a default value assigned in the Arguments panel? :slight_smile:

@loginerror
I am not sure what you are asking. My variable has a value that comes from a specific line in an email.

Indeed. And this means that it will work on runtime if the string value is correctly passed to the variable in the selector.

However, to properly validate the selector, you need to have a value somewhere. Currently, it most likely turns red because the string for that variable is empty.

You can navigate to the Arguments panel and give your variable a temporary variable for testing purposes :slight_smile:

@loginerror

Well, the string works in a message box, so I am not sure how it would be empty. I do not have a default value because the value comes from when the text from my email is stored in the variable. I guess I am not understanding what you are trying to say because I cant make up a value when it is going to be different everytime

What I mean is, you need the default value typed in for the selector to Validate to green in the design mode:
image

The way to do it would be to validate your selector using some values you know and then remove the values.
It will work on runtime given you provide the same values to the variable :slight_smile:

@loginerror
I want the aanmae= In_FileName instead of test_excel.xlsx. because it is going to store a new file in this variable each time that I run the bot as it pulls from a new email. But as soon as I try to change my selector to the variable name it does not want to validate it. But if I put the “test_excel.xlsx” as the default value it now wants to work. But I do not want this to always have this value, so that is confusing to me

image
image
image
However, even though it is validates when I set a default value, the click will not work.

Please add the Excel file name to the Default value field of your Arguments (or Variables) panel like so:

Then it will validate with the {{In_FileName}} in the selector.

This is only for testing purpose - the selector should still work on runtime, naturally.

If the problem happens on runtime, it would mean that the selector is not stable enough to handle this scenario (maybe).

@loginerror
Thats what I did and it validates but the click does not work.

What is the error that you are getting?

@loginerror
Do you have an idea on how I can click on the text stored in the variable without doing this? I cant move forward until this is done. I wanted to use the click activity to click on the file with the name of the variable.

Did you check that you are passing correct the name of the file to the variable? … could you print the variable before the click to be sure that you are giving ok the value or try with debug to check that.

@carmen

Yes, it prints the variable correctly when not using it in the selector

This is super strange. I would suggest you to try and debug your project. You can use the Step Into option in the Debug tab to go one activity at a time.

Could you then paste here the selector string at the moment before the activity is executed?
It will be visible in the Locals panel during debugging.