Inserting variable to selector

Hi,

I recently just encounter a problem where upon inserting a variable into the selector, I keep getting “element unknown” error. As seen from the bottom the original and the edited selector outputs are similar however, the edited selector is not able to work. Please help

Original selector: (able to work)
wnd app=‘iexplore.exe’ cls=‘Internet Explorer_Server’ /
uia name='Goods ’ role=‘list item’ /

Edited selector:
“wnd app=‘iexplore.exe’ cls=‘Internet Explorer_Server’ /
uia name=’ “+lineType.ToString()+” ’ role=‘list item’ /”

Editted selector output: (unable to work)
wnd app=‘iexplore.exe’ cls=‘Internet Explorer_Server’ /
uia name=’ Goods ’ role=‘list item’ /

*Disclaimer ive deleted away the <>

Hi,

It seems there are extra spaces ahead / behind variable.

Can you try the following?

"<wnd app='iexplore.exe' cls='Internet Explorer_Server' /><uia name='"+lineType.ToString()+"' role='list item' />"

Regards,

1 Like

Hi,

I just use your codes and for some reason it still doesnt work. It’s still giving me the same error. I am selecting this item from a dropdown.

HI,

Can you share content of lineType.ToString()?
If it is not "Goods " (there is a space after the word) but "Goods", can you try the following?

"<wnd app='iexplore.exe' cls='Internet Explorer_Server' /><uia name='"+lineType.ToString()+" ' role='list item' />"

Regards,

Hi,

There are suppose to be 7 spaces. And I have already tried the method below. However it still giving me error
"<wnd app='iexplore.exe' cls='Internet Explorer_Server' /><uia name='"+lineType.ToString()+" ' role='list item' />"

Hi,

There are suppose to be 7 spaces.

For now, to isolate problem, can you try the following selector (using wild card)?

"<wnd app='iexplore.exe' cls='Internet Explorer_Server' /><uia name='*"+lineType.ToString()+"*' role='list item' />"

Even if it works, we might need to modify it in order to improve more accurate.

Regards,

What error is it giving? Also the selector+variable should be pasted here in the properties
image

and NOT in selector editor

Hi,

Thank you so much! Now its works! What modify do I need to do tho?

Regards,

Hi,

Yup I did pasted it in the properties!

Hi,

If there is partial same words such as “Goods” and “Goods B”, it might not work properly. So can you try the following regex selector?

"<wnd app='iexplore.exe' cls='Internet Explorer_Server' /><uia name='\s*"+lineType.ToString()+"\s*' role='list item' matching:name='regex' />"

Regards,

If there is partial same words such as “Goods” and “Goods B”, it might not work properly. So can you try the following regex selector?

There are no same words all of them are different.

Regards,

Hi,

All right. Selector in #6 post will work in your case.

Regards,

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