Random Seconds Delay Not Working As Intended

Hello. I’m trying to create a random delay timer that generates between 1 min to a random number of seconds. The minute is working but the seconds are not. The bot is always running for exactly 1 min. Below is what I’ve done.

Added a multiple assign activity with variables as

waitTime = “00:01:” + randomSec.ToString
randomSec = New Random().Next(01,59)

In the delay activity, I set the duration to TimeSpan.Parse(waitTime)

Note: waitTime is a string while randomSec is an Int32 variable.

Refer to the below post. Hope it can help you.

Already saw this post. I get a compiler error when using this: TimeSpan.FromSeconds(waitTime)

Edit: Generating seconds between a particular range is not the issue. It’s how to combine the seconds with the predefined minutes.

In this order it will not work indeed:

But following code works like a charm…

intSec = New Random().Next(1,59)
strTime = "00:01:" + intSec.ToString
delay = TimeSpan.Parse(strTime)

Cheers

OMG guess what I only had to switch the randomSec and put it above the waitTime for it to work. It seems like UiPath needs to first generate the seconds, then parse and combine them with the minutes. Thx @J0ska.

I was fiddling with this not knowing where the issue is. Finally relieved.

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