Skip to content

Variables

Ian Holdsworth edited this page Nov 20, 2022 · 2 revisions

Easy Excel Framework

Variables Overview

In EasyExcelFramework we've tried to keep things as simple as possible so almost every variable assignment is in the format "Set > Variable > Value" although we support a few different variable types we've tried to keep these to a minimum as this tool is aimed at testers not developers (though Devs are welcome they may find it a bit Mickey Mouse). Note the default variable type is a string unless specified otherwise.

Scoping

Local variables are only available in the current worksheet whereas as the name implies Global variables are available throughout the Framework with the Caveat that when a worksheet is called with the Test Keyword it takes a copy of the Global variables at the time of calling and cannot change them outside of it's own scope

Actions

Local Variables

Set Local

Set's a local string variable

e.g.

Action
Set Local MyVar Hello World

Sets the local variable MyVar to "Hello World"

Set Local String

See Set Local

Set Local DateTime

Set's a local DateTime variable

e.g.

Action
Set Local DateTime MyDate 31/12/2030

Set's a local DateTime variable to "31st December 2030"

Note this can subsequently be used as a standard C# datetime variable so if you wanted to compare it to tomorrows date for example

Action
Set Local DateTime MyDate 31/12/2030
If MyDate==DateTime.Today.AddDays(1) Call AnotherSheet

Row 1 sets MyDate to 31st of Dec 2030
Row 2 says if MyDate equals Tomorrow (Today plus 1 day) then call "AnotherSheet"

Likewise we could specify MyDate.AddMonths(-1) to specify the previous month

Set Local Float

Set's a local Float variable

e.g.

Action
Set Local Float MyFloat 2.12358

Set's a local Floating point variable to 2.12358

Set Local Int

Set's a local Int variable

e.g.

Action
Set Local Int MyFloat 7

Set's a local Integer variable to 7

Globals

All the Same variables are supported with Global Scope utilising Set Global rather than Set Local

Parameters

Parameters can be passed to any Worksheet and referred to like any other variable as PARAM1 - PARAM???, however, to make life easier and to make things easier to read these parameters can be mapped to Local Variables via the Parameters Action

Example: Calling Worksheet\

Action
Set Local MyVar Test
MyWorksheet MyVar Test Value

MyWorksheet

Action
Parameters MyVarPassed TestVal
If MyVarPassed!="Test" ThrowException
If TestVal!="Test Value" ThrowException

The Calling Worksheet sets a local Variable MyVar to "test" and passes it and the value "Test Value" as the 1st & 2nd parameters of MyWorksheet.
On the 1st row of My Worksheet it calls Parameters with the names of the variables it wants to assign to those parameters We Then verify that the Parameters equal their expected values

Clone this wiki locally