Dynamic Timeout for UiAutomation Activities

Hello @UiPath_Community ,

How can I Set dynamic timeout for UiAutomation Activities (i.e Web Automation).

Example:
Let’s say I want to wait up to 1 minute (60 seconds) for a button to appear, but if the application is slow, I want to increase the timeout to 2 minutes (120 seconds).

Thanks & Regards,
Ronak Patel

2 Likes

Hi @ronak.patel
You can provide max timeout, if button appeared click and next operation otherwise wait till max time.

Or alternate you can use ,

If applicationIsSlow Then
dynamicTimeout = 120000
Else
dynamicTimeout = 60000

If you found helpful, feel free to tick as a solution.
Happy Automation

@ronak.patel,

I don’t think we can detect the application slowness so you can set the timeout to 120 seconds.

So even the Ui Element appears early, it will click on it without waiting for 120 seconds.

1 Like

You can apply Retry scope activity to handle this situation. If the UI element is not available at first 60 seconds, bot will try for another 60 seconds to get the Ui element.

1 Like

Hi @ronak.patel

You can take 2 approaches here:

  1. already shared by @manasrlenka25

  2. you can define an asset for timeout value. And provide the same in timeout property of the activity. So, if after multiple runs, you have observed that activity is failing(because application is taking more time to load), you can increase the timeout in orchestrator and re-run to observe if it improves the situation.

If you have multiple activities where you would want to control the timeout range, I would suggest creating 3 assets for timeout like “short timeout”, “medium time out” and “long time out”.

Based on your observations from test runs, you can accordingly adjust the values and use it at different places.

Hope this helps.

Regards
Sonali

1 Like

Hi @ronak.patel
You can try below steps
UiPath activities like Click, Type Into, Element Exists, etc. have a Timeout (milliseconds) property.
Normally, you hardcode a value (like 30000 for 30 seconds).
But if you want dynamic timeout — you can set it through a variable.
Hope it works for you!

@ronak.patel thank you for reaching out.

Can you give Healing Agent a try for your scenario? One of its use cases is to detect if application loads slowly and adapt.

Here are more details on how to set it up and use it.
UiPath Healing Agent Community Public Preview - News / Product News - UiPath Community Forum

You don’t need it to be dynamic. Just set the timeout to more than the maximum amount of time it will ever take. The activity executes as soon as it can, it doesn’t wait the whole timeout every time.

Please set the timeout with some buffer on top of it and you can utilize On Element Appear activity which allows you to waits for a UI element to appear and enables you to perform multiple actions within it.

Why are you using classic activities? It’s long past time you should be working in modern. Check App State is far superior to On Element Appear.

2 Likes