Get Text - Verify

Get Text Activity can get the text from a web page. Some times get the empty text that may caused by page loading delay.
What’s the best practice to make sure we can get text every time?

HI,

In this case, we can use Retry Scope, for example, as the following.
If grabbed value is empty, retry “GetText”.

Regards,

Hey,

you can use Element Exist, So you will check for the element
then after you can apply if else condition pass the output of Element Exist , if it is true the you can use Get text ACtivity

Thanks,
Rounak

Hi @AndrewGuo, I hope you are doing well.
For the problem stated by you, it is always feasible to use “Element Exists” or “On Element appear” before going with a click or get text activity. And to handle it more safely you can also bound the get text activity inside a retry scope.

I hope all this points will help you to solve your problem.

Thanks & Regards,
Shubham Dutta

Thanks all for your help. The solution works

For a general case, it’s a little verbose if there’re many texts need to be verify.

What’s the best practice when working with many of them?

I’d think maybe something like the following pseudo-code.

But if I create a new sequence for MustGetText, it can’t just pass the UI element, it need be wrapped into a Browser/Application activity.

How do you implement it in UiPath?

func main() {
    name = MustGetText(nameElement)
    address = MustGetText(addressElement)
    ...
}

func MustGetText(theUIElement) String {
    text = ""
    // or Retry activity
    do {
        // not work, need a wrapper
        text = Get Text Activity(theUiElement)
    while (text != "")
    
    return text
}

You’re overcomplicating it.

Use a Check App State and look for a consistent element, to make sure the page is loaded before you do the Get Text.

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