Decision based on varying UI element

Hi,

On a website I need to check a UI element to see if it is 0kg or near 0kg. If “YES” click “CLOSE”, if NO do another action.

However, the UI element is not constant. There are some small changes in it as shown below:
open pix1 openpix2 openpix3 open pix 4 open pix 5 open pix 6
image
image
image

I am using an “Anchor” activity on the “Open:” and a “Get Text” activity on the left part.

I am saving my Get Text in a “openText” variable. I splitted it using the code below:

openText = openText.Split(" "C)(1)

My If statement is as follows:

But I am not able to cater for every event. Can someone help me please?

Thanks!

As you’ve said you’re working with a webpage try with “get attribute” activity… which will fetch the underlying value so simply you can use contains method to validate.

That’s the thing. I have too many events to check: 0.01, 0.03, 0, …

As shown in the screenshot above, two main UI Element are recurrent:

  • Open: ca. 0.0xkg
    So we need to check x if it is <1 or 0 at all times.

  • Open: 0kg(xkg)
    Here, we need to check the 0kg only as x can be -6.7 as shown in screenshot.

  1. When it is, for example: Open: ca. 0.01kg, I want to extract only the “0.01” and check if it is less than 1.

  2. When it is, for emaple: Open: 0kg(0.01)kg, I want to extract only the first part “0kg” and check if it is 0.

Can we do that?

@Yudhisteer_Chintaram1 -

  1. Use the Contains conditions to check if the text has ca.

  2. If ca. presents then use the below regex pattern to extract the value and check if its < 1, if not proceed as per your requirement

    (?<=ca\.\s+)[\d.]+
    
  3. Step 1 else part, use the below regex pattern to extract the value and check if its 0…then proceed

^\d{1}(?=kg)

Hope this helps…

1 Like

Hey @prasath17 ,

Thanks for the help!
Just to confirm since I am not that pro in Regex. So my code become like this:

openText = System.Text.RegularExpressions.Regex.Match(your_String,“(?<=ca.\s+)[\d.]+”).Value

openText = System.Text.RegularExpressions.Regex.Match(your_String,“^\d{1}(?=kg)”).Value

Do I use an assign activity or Invoke code activity?

@Yudhisteer_Chintaram1 - Your code looks good…

Assign Activity should be good…

Okay let me try that.

1 Like

@Yudhisteer_Chintaram1 - you have to convert the value to check if its < 1 . Please find the sample below…

Note: Here Strsample = “ca. 0.08kg”

1 Like

Works like a charm!
Thanks!

1 Like

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