Flexible or conditional selectors

Hi all!

I’m facing a challenge. In automation process a window with data pops up. The automation is to get text from one cell. It turns out the pop-up window comes in 2 versions. Depends on version the cell’s address (highlighted in the picutre below) changes:
image

  1. idx = 59
  2. idx = 9

What shoud I do in order do make the selector accept both numbers depends on pop-up window version?

Best regards,
Piotr

1 Like

Hi @Piotrek_Murawski

First let’s get the id value using GET ATTRIBUTE activity and save that in a string variable

Use a IF condition like this

Strinput.ToString.Contains(“59”)

If true then it goes to THEN part where keep a activity with Id as 59 in its selector
Or
It will go to ELSE part where use a activity with Id as 9 in it selector

Hope this would help you resolve this

Cheers

Hi @Piotrek_Murawski

Method 1:

  • Save both the selectors in two variables
  • Use Element exist for popups
  • If 1st Popup exist
    idx = 59 (Use this selector)
    Else
    • if 2nd popup exists
      idx= 9

Method 2:

  • Use Switch Activity
    Based upon the option you can use both the selectors

Regards
Sudharsan

@Piotrek_Murawski

You can use Regular expression in selector.

              <wnd cls='Edit'  idx='[0-9]{1,2}' matching:idx='regex' />

Have a look below thread to know more about using Regular expression in Selectors.

If you’ve got an idx of 59 in your selector, you need a better selector. Edit it to add other properties so the idx goes away.