You are on page 1of 35

Day 2: Foundation training

Automation Anywhere –  Variable creation and usage


Foundation Training  Loop Command
 If-else command
 Excel Command
 Lab Exercises

Confidential © Copyright 2015 Avanade Inc. All Rights Reserved.


© 2015 Avanade Inc. All Rights Reserved.
Variables – Creation and Usage 2.1

Add new variable

© 2015 Avanade Inc. All Rights Reserved. 2


Variable Contd..

Select type of variable

© 2015 Avanade Inc. All Rights Reserved. 3


Variable Contd..

Select source for values in variable

© 2015 Avanade Inc. All Rights Reserved. 4


Variable Contd..

Option to initialize values

© 2015 Avanade Inc. All Rights Reserved. 5


Variable Operation

 Perform mathematical functions


 Add/subtract calendar days
 Used to populate initial variable
assignments Output Variable
 Used for making custom counters
 Overwrites existing data in variable

New Value for


Output
 Use existing
variables

© 2015 Avanade Inc. All Rights Reserved.


Variable Demos

• Pick Variable from text File


• Create List Variable
• Create List Variable from Text File
• Loop through List Variable
• Create Random variable

© 2015 Avanade Inc. All Rights Reserved. 7


If/Else Command

• Use this command to add conditional logic and actions to


your automated task. The IF/ELSE command provides the
following sub-commands
– File Exists / File Does Not Exist
– Folder Exists / Folder Does Not Exist
– Window Exists / Window Does Not Exist
– Application Running / Application Not Running
– Script Successful / Script Unsuccessful
– Task Successful / Task Unsuccessful
– Ping Successful / Ping Unsuccessful
– Variable
– File Size
– File Date
– Web Control
– Image Recognition
– Service Running / Service Not Running
– Windows Control
– Else If
– Else
– End If

© 2015 Avanade Inc. All Rights Reserved. 8


If/Else Command -- Pattern

1) If (Condition)
Execute commands/actions only when condition is true
End If

2) If (Condition 1)
Execute commands/actions only when condition is true
Else if(Condition 2)
Execute other commands/actions when Condition 2 is true
Else if(Condition 3)
Execute other commands/actions when Condition 3 is true
Else
Execute commands/actions when condition 1,2 and 3 are false
End If

© 2015 Avanade Inc. All Rights Reserved. 9


If/Else Command – Sub Commands

• Window Exists/Window Does Not Exist Commands


• Use these commands to do the following:
• Check or verify that a specific application is open.

© 2015 Avanade Inc. All Rights Reserved. 10


If/Else Command – Sub Commands

Application Running/Application Not Running


Commands
• Use these commands to perform an action based on
whether an application is running. When a program is
running in the background, you can still perform actions by
using this command.

© 2015 Avanade Inc. All Rights Reserved. 11


If/Else Command – Sub Commands

• Task Successful/Task Unsuccessful Commands


• Use these commands to run several Automation Anywhere
tasks, one after another. The command runs the selected
task, and depending on the return code, determines if it
ran successfully and takes appropriate actions based on
the result.
• For example, if a task that monitors your website runs
successfully, it means that your website is up and no
action is required. However, if the task is unsuccessful, it
means that the website is down and you need to take
action.

© 2015 Avanade Inc. All Rights Reserved. 12


If/Else Command – Sub Commands

• Variable Command
• This command, though it looks simple, is perhaps the most
powerful conditional command. Use this command to
perform hundreds of checks..

© 2015 Avanade Inc. All Rights Reserved. 13


If/Else Command – Sub Commands

• Web Control Command


• Use this command to identify whether a specific web
control exists on a Web page. For example, your task can
check for links, text boxes, and drop-down menus. Use
this command when editing tasks that are created using
the Web Recorder.

© 2015 Avanade Inc. All Rights Reserved. 14


If/Else Command – Sub Commands

Windows Control Command


• Use this command to check whether a specific control
exists in an active window. For example, you might check
for command buttons, list box items, text boxes, or menu
tabs.

© 2015 Avanade Inc. All Rights Reserved. 15


If/Else Command – Sub Commands

Image Recognition Command


• Use this command to check whether an image exists
within another image. Automation Anywhere can recognize
images that are stored in files or captured from a window
when the task runs.

© 2015 Avanade Inc. All Rights Reserved. 16


If/Else Command – Sub Commands

Setting a Wait Time for Conditions


• Most of the conditional commands let you specify how long to wait for a condition to be true.
• Let's say you want to perform an action only if a specific window exists. You know that it might take from 5 seconds to 5
minutes for the window to open. Obviously, you don't want to wait 5 minutes when the window comes up in just 30
seconds. Automation Anywhere takes care of this for you by following this model:
• Using the IF command, you can select IF and 'Window does not exist,' and type the maximum time in seconds to wait for
the window to be displayed. (In this case, 5 minutes, or 300 seconds.)

© 2015 Avanade Inc. All Rights Reserved. 17


Loop Command

• Use this command to create loop structures in your


automation task to automate repetitive tasks.
• The LOOP command provides the following sub-
commands:
• Start Loop
– Times
– List
– Condition
– Each Row in an Excel Dataset
– Each Row in an Internet Explorer Table
– Each Row in an SQL Query Dataset
– Each File in a Folder
– Each Folder in a Folder
– Each Row in a CSV/Text File
– Each Email Message on Server
– Each Node in an XML Dataset
• End Loop
• Exit Loop
• Continue Loop

© 2015 Avanade Inc. All Rights Reserved. 18


Loop Command – Sub Commands

Start Loop Times


• Use this command to loop for a number of times. The
command loops the actions between the Start Loop and
End Loop commands for the number of times you specify.
For example, if you want to repeat the action 5 times,
place the actions between Start Loop and End Loop
commands and specify 5.

• It’s a good practice to use a variable instead of hardcoded


values like 5 .

© 2015 Avanade Inc. All Rights Reserved. 19


Loop Command – Sub Commands

Start Loop List


• Use this command when you do not know how many times
a task needs to loop. If you have a list variable that
contains several values, you can use the List command to
loop through the entire list until it reaches the end.

© 2015 Avanade Inc. All Rights Reserved. 20


Loop Command – Sub Commands

Start Loop Condition


• Use this command to run actions based on conditions that
exist. For example, you might want to repeat a set of
actions based on whether a file exists.

© 2015 Avanade Inc. All Rights Reserved. 21


Loop Command – Sub Commands

Each row in an Excel Dataset


• Use this command in conjunction with the Get Multiple
Cells sub-command of the Excel command. When you
have retrieved a range of cells from Excel using Excel >
Get Cells > Get Multiple Cells, the rows and columns of
the range are stored in the system variable $Excel
Column$.
• For example, if you retrieve a range of cells from Excel
that has five columns, you can access the five columns of
the table by calling $Excel Column(1)$, $Excel
Column(2)$, $Excel Column(3)$, $Excel Column(4)$,
$Excel Column(5)$. This command is extremely useful for
transferring data from one Excel spreadsheet to another,
or to any other application.
• Similarly use Each Row in a CSV/Text File.

© 2015 Avanade Inc. All Rights Reserved. 22


Loop Command – Sub Commands

• End Loop Command


• Use this command to end the loop. The actions that exist
between the Start Loop and End Loop commands will
repeat based on the type of loop you have selected.
• Whenever you insert a Start Loop command, an End Loop
command is also inserted. If the End Loop is mistakenly
deleted, you can insert an new one.
Exit Loop Command
• Use this command to break out from a loop when a
particular action or condition occurs. The Exit Loop
command can exist only between the Start Loop and End
Loop commands.
Continue Loop Command
• Use this command to continue the next iteration of a loop
when a particular action or condition occurs. When a
Continue Loop command is reached, the commands up to
End Loop are skipped and the next iteration of the loop is
run.

© 2015 Avanade Inc. All Rights Reserved. 23


Excel Command

• The Excel command is one of the most powerful commands provided by Automation Anywhere. Microsoft Excel is one of
the most highly used applications in the world today.
• Many Excel automation scenarios have been implemented by companies worldwide. Some common scenarios include:
– Copying data from one Excel spreadsheet to another.
– Extracting data from an application to an Excel spreadsheet.
– Extracting data from a website to an Excel spreadsheet.
– Moving data from an Excel spreadsheet to another application.
– Transfer data from Microsoft Access to Excel.
– Transfer Excel data to a website form.

© 2015 Avanade Inc. All Rights Reserved. 24


Excel Command – Sub Commands

• Sub-Commands
• The Excel command provides the following sub-commands:
– Open Spreadsheet
– Close Spreadsheet
– Activate Sheet
– Get Cells
– Set Cell
– Go To Cell
– Run Excel Macro
– Delete Cells
– Save Spreadsheet
– Find/Replace

Excel Command is mostly used in conjunction with Loop Command

© 2015 Avanade Inc. All Rights Reserved. 25


Excel Command – Sub Commands

• Open Spreadsheet Command


– Use this command to open an Excel spreadsheet.
– If your task involves working with many spreadsheets
and workbooks, you can specify the session name
– In advanced view you can also specify password if required.

 Variables should be used for spreadsheet path instead of hard coded


file path like ‘C:\HR\Employees.xls” It’s a good practice to store
spreadsheet path in some external source like notepad and read that
information in variables.
 If you are opening multiple spreadsheets in a single task make sure
to provide a different session name.

© 2015 Avanade Inc. All Rights Reserved. 26


Excel Command – Sub Commands

• Close Spreadsheet Command


– Use this command to complement the Open Spreadsheet command.
– It closes a spreadsheet that is previously opened using
an Open Spreadsheet command.

 Always make sure to close the spreadsheet after its not required.
 If you don’t want to save changes then check the “Do not save
changes” box.

© 2015 Avanade Inc. All Rights Reserved. 27


Excel Command – Sub Commands

• Activate Sheet Command


• Use this command to activate a specific spreadsheet in an
open workbook.

© 2015 Avanade Inc. All Rights Reserved. 28


Excel Command – Sub Commands

Set Cells Command


• Use this command to set the value of the active cell or a
specific cell in an Excel spreadsheet previously opened
using the Open Spreadsheet command.
• You can also use a variable to assign the value in the cell.

© 2015 Avanade Inc. All Rights Reserved. 29


Excel Command – Sub Commands

• Get Cells Command


• Use this command to retrieve the values of the active cell
or a specific cell, as well as a range of cells from the
spreadsheet opened by the Open Spreadsheet command.
• When you retrieve values for an active or specific cell, you
can assign the value to a variable.
• When retrieving values from multiple cells, the values are
assigned to an $Excel Column(index)$ system variable.
You can use this variable in subsequent commands, for
example, to loop through each row in the spreadsheet.
• Always do a validation of the type of data stored in the file.
• For Loop Each Row in a Excel Dataset always follows
Get Multiple Cells.

© 2015 Avanade Inc. All Rights Reserved. 30


Excel Command –Sub Commands

• Go to Cell Command
• Use this command to move to a specific cell. The
movement options include:
– Move one cell to the left or to the right of the active cell
– Move one cell above or below the active cell
– Move to the beginning or end of a row or column within
a spreadsheet that was previously opened using the
Open Spreadsheet command

© 2015 Avanade Inc. All Rights Reserved. 31


Excel Command – Sub Commands

Run Excel Macro Command


• Use this command to run an Excel macro that is stored
within an Excel spreadsheet that was previously opened
with the Open Spreadsheet command.
• Always store Macro names in external source and use
variables to provide the macro name. this makes your task
more flexible in case of any change in macro name.

© 2015 Avanade Inc. All Rights Reserved. 32


Excel Command – Sub Commands

Delete Cells Command


• Use this command to delete the values in the active cell or
in a specific cell within an Excel spreadsheet that was
previously opened using the Open Spreadsheet command.

© 2015 Avanade Inc. All Rights Reserved. 33


Excel Command – Sub Commands

• Save Spreadsheet Command


• Use this command to save a spreadsheet in an open
workbook.

© 2015 Avanade Inc. All Rights Reserved. 34


Questions?

© 2015 Avanade Inc. All Rights Reserved. 35

You might also like