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


#1

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!!


#2

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.


#3

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


#4

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.


#5

How to pass variable in Extract Meta Data property?


#6

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


#7

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.


#8

lets try, dynamic value is Variable yes


#9

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


#10

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)


#11

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