How to write condition in IF statement to check whether Timespan is more than 30 seonds

Part of a Workflow that I am building needs to measure the time elapsed between two the opening of a Webpage and the appearance of Ui Element on the page. I have made use of the Stopwatch object in VB.NET to measure the time that has elapsed between two time intervals. From the Stopwatch object I have obtained TimeSpan value. My question is how do I compare the TimeSpan value with a set value.
I am required to do certain actions if the time spent between opening of the Webpage and the appearance of Ui Element on the page is more than 30 seconds

But how do I write a boolean expression something like

Timespan > 30 seconds into the condition of the IF activity? I tried doing the following but it shows an error

image

Kindly assist. Thank you.

Hi @RobinsonFrancis,

You can use this.

YourVariables.TotalSeconds>30

Can’t you get around this using element exist? If you leave the timeout field as default, after 30 seconds the boolen will be false and you can use

image
image

Regards,
MY

declare 2 datetime variables
image

assign startTime = Now after browser open
image

assign endTime = Now after element is found
image

now you can check the time elapsed using
endtime.subtract(startTime).TotalMilliseconds
image

1 Like

Hi,

It might be better to use StopWatch.ElapsedMilliseconds instead of StopWatch.Elapsed. Because this returns int64 value and we can easily write the condition as the following.

Regards,

Thanks @muhammedyuzuak, @Yoichi and @jack.chan I have tried all your suggestions. They are really good suggestions.

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