SOLVED - Dynamic selector with logical OR

Hi,

I want to use a “OR-Condition” for an aaname value in a selector. I am often faced to login pages. Those are sometimes in englisch, sometimes in german language. So, aaname of the Login-Button is “Login” or “Anmelden”.

I know that it works, because I already did it… long time ago in a project, i cannot find anymore :wink:

So, I want something like this:

html app=‘chrome.exe’
webctrl tag=‘BUTTON’ aaname=‘Login’ || ‘Anmelden’

Does anyone know how to make it - it should be an easy syntax in the UI Explorer.

I post this question to get known, how to deal with those topics in an elegant way. Please do not answer, if you do not know the answer. I don’t want a workarround.

Thank you and regards,
Jan

Hi @jan.smedseng

Try this:
<webctrl tag='BUTTON' aaname='Login|Anmelden' />

No, does not work in my case, sorry.

@jan.smedseng

<webctrl app='chrome.exe' tag='BUTTON' aaname='Login' idx='1' />
<webctrl app='chrome.exe' tag='BUTTON' aaname='Anmelden' idx='2' />

The idx attribute represents the ordinal position of an element that matches the other specified attributes. In this case, you can use it to select the first element that matches either “Login” or “Anmelden”.

Or try this:

<webctrl app='chrome.exe' tag='BUTTON' aaname='Login' />
<webctrl app='chrome.exe' tag='BUTTON' aaname='Anmelden' />

Hey @jan.smedseng,

Can you try

<webctrl tag='BUTTON' aaname='Login|Anmelden' matching:aaname='regex' />

Hey @jan.smedseng ,
I have 2 methods

  1. Open the UiExplorer by clicking on the “Indicate Element” button in the UiPath Studio, and then click on “Indicate Element” again.
    In the UiExplorer, find the “aaname” attribute and click on the small edit button (pencil icon) next to it.Replace the existing selector value with the following:
<webctrl tag='BUTTON' aaname='Login' />
<webctrl tag='BUTTON' aaname='Anmelden' />

This creates two separate lines in the selector, each representing a different language option. UiPath will try to find the element using the first line. If it doesn’t find any matching element, it will automatically switch to the next line, which represents the other language option.

2.Assign the selector as

<html app='chrome.exe'>
<webctrl tag='BUTTON' aaname='{{loginButtonText}}' />

the value to the loginButtonText variable based on the language or other conditions. For example:

  • If the language is English: loginButtonText = "Login"
  • If the language is German: loginButtonText = "Anmelden"

This way, you can make your selector dynamic and handle different languages effectively. It requires a bit of setup to set the loginButtonText variable correctly, but it should work as expected.

Hope it helps you

Thank you, thats it :smiley:

1 Like

Glad to be of help, @jan.smedseng

1 Like

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