How to set Delay duration with string in UiPath

The Delay activity is an essential function in RPA

In Robotic Process Automation (RPA), a common control to ensure the robot is able to interact with the application/website smoothly is the “wait for something to happen” function. For example, the robot should wait for X seconds and continue with the next step.

By using the “Delay” activity in UiPath, the robot can wait based on the specified duration before moving on. The easiest way is to hardcode the duration in UiPath.

The duration above shows a delay activity of 5 seconds, hardcoded in the Delay activity properties.

Setting duration with a string variable

In RPA, it is quite common to set dynamic items such as wait time, URL in a separate file. For example, settings in the REframework are done in the Config file. We can also configure the wait time (how many seconds to wait) in the Config file as well.

Goal of this tutorial

In this article, you will learn how to get number of seconds from an Excel file and use it in the Delay activity.

There are 2 simple steps to do this:

  1. Read an Excel file with the number of seconds
  2. Write the number of seconds into the Delay activity

1. Read an Excel file with the number of seconds

Below is a simple Excel file with the number of seconds to delay. We will load this Excel table as a datatable in UiPath.

Load the Excel table into a datatable called “excelTable” using the Excel Application Scope and Read Range activities.

2. Write the number of seconds into the Delay activity

After specifying the number of seconds, let’s put this information into the Delay activity. First, drop a Delay activity into the workflow.

Next, fill up the following VB expression in the Duration properties of the Delay activity:

TimeSpan.parse("0:00:" + excelTable.Rows(0).Item("Number of seconds to wait").ToString)

This VB expression uses the timespan.parse expression to parse “0:00:” and the seconds to wait together.

The exceltable.Rows(0) will take seconds from the first row in the Excel table (Delay Name — Short).

Similarly, to get number of seconds to wait for Medium, simply change the row integer to 1.

Happy automating!

--

--

--

is writing about UiPath — robotic process automation

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creating Fluent Interfaces Using Lambda Expressions

Your CLI Tool Should be a Server (Maybe)

Looping through an S3 Bucket and performing actions using the AWS-CLI and BASH

Chapter 3 Adding Content Sections

Elastic Search on Windows using Filebeat

What I Wish I Knew Before Starting My Computer Science Degree

A laptop with code on a desk.

Calm | Internet Explorer — https://t.co/pOYiHLUdPq | Internet Explorer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
fenlim

fenlim

is writing about UiPath — robotic process automation

More from Medium

System Modelling and Performance Estimation

Timed Automata and Application

Participant story: Adaora

Black woman with two buns on top of her head and twists hanging down on either side

How to Configure Local Preference in BGP