Variable in a selector (solutions from forum don't work)

Hello, I have a question about inserting a variable into selecter.

Here’s the original syntax with static values:
I need to use a variable (e.g. Row) instead of the static value 5. I tried to search all relevant posts here, but none of the suggested syntaxes worked. We tried several versions including:
<sap id = 'usr / lbl [43, ’ +Row+ ‘]’ />
<sap id = ‘usr / lbl [43, ‘" +Row+ "’]’ />
and several other variations but we get a syntax error most of the times and cannot continue. Often the problem seems to be that it does not recognice the variable as a variable.

In the case when we managed to get it to recognized it as a variable the robot ended with an error:

Cannot find the UI element corresponding to this selector: <wnd app='saplogon.exe' cls='SAP_FRONTEND_SESSION' title='Sledování vzájemných zápočtů (verze 2.11 build 18.10.2007)' /><sap id='usr/lbl[43,&quot;+ Row+&quot;]' />

What are we doing wrong? How should the syntax look like?

Thank you!!

Put it exactly as below directly in Selector property:
"<wnd app='saplogon.exe' cls='SAP_FRONTEND_SESSION' title='Sledování vzájemných zápočtů (verze 2.11 build 18.10.2007)' /><sap id='usr/lbl[43," + Row.ToString + "]' />"

Make sure you’re not using Selector editor, as it will encode the quotes for XML (hence the &quot; there).
Once you have the selector string as the expression, pressing the ... button will open the Expression editor which will work normally and not encode anything.

1 Like

pressing the … button opens up the selector editor. I have the same problem- " changes to &quot. How to fix it?

I’m not sure if this is the best solution but what we did was create a variable to which we assigned a value equal to the selector that we wanted and than just put the variable as the only thing into the selector. It seems to work fine so far.

How to pass variable in Extract Meta Data property?

i tried so many ways to insert a variable in selector but it is not working, let see i’m upload error images. any one know another method or solution please let me know1method2method3method

chinnapureddy03
Below is another way to add variable in selector:

  1. Assign the selector in a variable with a place holder {0}
    varSource = “”
    image

  2. USe string.Format to assign the dynamic value
    varSelector = String.Format(varSource,“DynamicValue”)
    image

  3. Assign the variable in selector property
    image

Please let me know if this works.

lets try, dynamic value is Variable yes

It is not working Madhavi, I’m uploading Images, please go trough it and tell me any mistake in my process
1.image

2.Image

3.Error

DynamicValueError

Hi chinnapureddy03,

Give a try to the folowing approach and let me know if it worked for you!

BaraHow to use a variable inside of a selector.pdf (306.1 KB)

1 Like

@barbora.m thank you so much yar, it is working … thank you soooo much

2 Likes

@Madhavi_Jaiswal
Hi Madhvi
In Selector I am getting below Code what is my understanding is this is not a table But in sap its view like table structure.

Can you give little bit of explanation on how can we scarp it. Its series of shipment number.
usr/lbl[8,4]

Thanks

Dont press the “…” button. Just click on the editable text field and input there :slight_smile:

That was helpful. Although initially when I pressed the … next to the selector, it opened the UI Explorer. I had to literally type in the variable name etc in place, without even clicking on the …