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!