How to get the count a specific word appears on a webpage with variable text to use it on a If/then workflow?

I would like the bot to go into a webpage each time and look for how many times the word “Email sent” appears. This webpage has variable text meaning the text is not the same each time the webpage is accessed. I will use that result on a If/then activity later. What is the best way of doing this?


Use Get Text to get the text of the page.

Then on that string…


1 Like

Hello @zachelle

Will it be possible to share a screenshot of the application and where you want to find the text?

Also, it would be better to give more insights into your use case to suggest other alternatives.


If i understood correctly I should use the get text activity. Create a variable to store the scraped text and then on an assign activity I will use the suggested regex.

If the variable name is “scraped” the assign activity should look like this?

scraped = System.Text.RegularExpressions.Regex.Matches(scraped,Email sent).Count

Not quite. String literals go in double quotes.

System.Text.RegularExpressions.Regex.Matches(scraped,“Email sent”).Count

Sorry I did not noticed your message earlier. I am not able to show you a screenshot of the webpage but if you have any suggestions on how to accomplish this task please let me know. I would love to try it.


I have tried your suggestion but it is not working. I am receiving a message stating "compiler error(s) encountered processing expression System.Text.RegularExpressions.Regex.Matches(scraped,“Email sent”).Count Option Strict On disallows implicit conversions from integer to string.

Hi @zachelle

Add .ToString at the last

That was the missing part. Thank You!

The field were is supposed to get the text is a few individual boxes on the webpage. With Get Text I can only select the word on one of the boxes but it will not read from any of the other boxes. Is there another way to read the entire page to recognize the other boxes?

Hi @zachelle

Well one option would be reading all the text in webpage using GetText and then getting count

But if you had tried that already and still not getting results, then I would suggest this approach

Using javascript you can find the numbers of times an element text is occurring

Using inject js activity in UiPath l, u can invoke js code in UiPath

May be u can try that approach

For reference you can use this

Hope this helps

Thanks & Regards,
Nived N

Don’t copy/paste from the forum into UiPath Studio. You get the wrong double quote that way.

Retype things.