Click Activity with Regex

Im not so familiar with Regex.
I would like to add a Regex inside the Click activity.

The Regex should search if two specific words are in that line. If a String has these would in any order it should click on it.

Also if none of the Strings fulfill the condition, the activity should click on one string where at least one of them is available.

So for example:

The two words are aaname=‘company and invoice

The strings are:

– machines of company x

– work done by computer

– Invoice of company ABC

– tools of the process

so the click activity should chouse the line “Invoice of company ABC

Thanks in advance

Hi @Okan

Fetch the data and assign it in variable. After that use if activity, and provide condition has below.

If condition: System.Text.RegularExpressions.Regex.IsMatch(stringValue,"(?=Invoice|invoice).+(?:Company|company)") or System.Text.RegularExpressions.Regex.IsMatch(stringValue,"(?=Company|company).+(?:Invoice|invoice)")

Keep click activity under then part in ‘IF’ activity.

So it will click when the condition is matches.

Feel free to reach us at any time if you have doubts. Thanks.

Happy Automation

Hi @vignesh.ks

Thank you for your solution.

How should I define the selector inside the click activity?

Hi @Okan

You can indicate the element which you want to click. And under aaname or innertext you can pass the variable which we got from get text activity. Thanks.

Hi @vignesh.ks

Thank you for your fast reply.
Now i get an error from the Click activity “Cannot find the UI element corresponding to this selector”

What I have forget to mention, is that I work on a website with many Hyperlinks in which the click activity should chouse, with the Regex Selector and continue by clicking on it.

Hi @Okan

Is it possible to share the website link?

Thanks.

Hi @vignesh.ks

It´s from the google search result field.

Thank you

Hi,

Can you try the following?

<webctrl aaname='[Cc]ompany.*[Ii]nvoice|[Ii]nvoice.*[Cc]ompany' matching:aaname='regex' />

Also if none of the Strings fulfill the condition, the activity should click on one string where at least one of them is available.

It’s difficult to achieve both requirement with single regex. Perhaps you need to use If activity etc.

Regards,

Hi @Yoichi

Thank you for your idea.

I tried it aswell, unfortunately I get the same error: “Cannot find the UI element corresponding to this selector

ass you can see from the screenshot, i tried with and without the css-selector.

Hi,

Can you try to remove tag=‘H*’ or modify tag=‘H3’ etc because it doesn’t seems to support wildcard in Tag attribute?

Regards,

still the same issue.
With and without tag=‘H3’

Hi,

In my environment, the following selector works. Is there any difference with yours?

Regards,

Hi @Yoichi

I have no idea, why it didn’t work for me.

Do I need an extra packet installed?

Or is it because I do a For Each Loop inside the attach browser activity?

Or because I have the Pro Edition and not the community Edition?

Somehow the regex don’t work.

Thank you so far.

Hi,

Probably yes.

If I put the activity inside OpenBrowser, validator returns success.
However, if I put it inside AttachBrowser, validator returns fail, even though it works in actual run.

The following is sample workflow. Hope it helps you.

Sample20210421-1.zip (2.7 KB)

Regards,

Hi @Okan

Please find the below screen shot for your reference.

workflow:

If condition:

System.Text.RegularExpressions.Regex.IsMatch(outputAaname,"(?=Invoice|invoice).+(?:Company|company)") or System.Text.RegularExpressions.Regex.IsMatch(outputAaname,"(?=Company|company).+(?:Invoice|invoice)")

Click Selector:

So it will click only the condition matches. Thanks.

Hi @vignesh.ks

Thank you for your reply.

Like as seen on the screenshot I did everything exactly like yours but still get an error.

I tried it on my project and even independent like on you solution.

Hi @Okan

Could you please show me the selector of click activity. Thanks.

Hi @vignesh.ks

sure.

Thank you

Hi again @Okan

Remove &quot;+ from the selector and give a try like given in the below screen shot.

Thanks.

Hi @vignesh.ks

Thank you very much. Now it works realy fine!!

So with the Expression System.Text.RegularExpressions.Regex.IsMatch I can work as I want with Regex, while extracting specific Text Elements.

Gone check out some Tutorials for RegEx too.

Thanks a lot for your help!

1 Like