Following the Testcase walkthroughs, we should be in a position to begin consolidating the test pack into reoccurring test steps and bespoke functionality. This is not to say, all eventualities should be catered for, however having a structured understanding of the AUT and Test Pack allows easier development of the automation project.
EPF Script Hierarchy Definitions
- Config: Contains all the properties of this framework (i.e. SUTs, Search Rectangles and Data entry offsets, etc)
- Common: Generic functions to automate a particular platform
- Custom: Specific functions created using core functions or bespoke functions to automate the specific project
- DAI Wrappers: When using a DAI model framework - Maintainable relationship between DAI and the framework (See Model Based TestCases)
- Test: When frameworks outside of DAI – Container for Script Based Testing (See Script Based TestCases)
The Config script contains all parameters and configuration data that is to be used within the other scripts. This is to avoid hardcoding values in the test scripts.
This Config script introduces the mindset of isolating static content into a single and referenceable area.
In the example below, we want to expand the testcase to work on multiple browsers. Referring back to our OCR Best Practice, of reducing the search space, we need to ensure each browser size is catered for, to optimise the OCR search.
As we can see, while subtle, each browser has different sized areas where the rendered content is displayed:
Below in the 'browsers' section of the config script, is each area translated into coordinates for 1920 x 1080 resolution.
Config - Configuration Parameters to be used in other scripts
@Version 1.0 01/11/2022
To simply get these areas, use the capture screen in Eggplant Functional, create the capture box and use Control+c and paste into the snippet window.
The functions will then reference the configuration parameters (Offsets, SearchRectangles etc) as shown in the following examples:
to AppSwitcher varlogos:logos,app
set global app to app
typetext altkey, tabkey
assert that ImageFound(10,image:varlogos,searchRectangle:(config().browsers.(global browser)))
to checkBox label, offset:(config().dataEntry.checkBoxOffset)
click the CenterLeft of scrollTo(label) + offset
The Common script contains all the reusable functions (handlers) that are to be used in the test scripts. These functions are parameterised to make them as modular and reusable as possible.
Scripting in this way increases efficiency and decreases the amount of separate similar functions that would be needed.
to textEntry label,input
doubleclick CenterLeft of scrollTo(label) + (200,0)
to closeTab expectation
if expectation is not empty
Calling these functions will be done by the following:
common.textEntry "Timer Name", name
Custom scripts primarily use the functions in the common script where possible, but may also include customised code/functionality which will not be used again in any other function, for example, in complex scenarios.
Depending on the project complexity, this can be a single 'Custom' script which contains handlers, or a 'Custom' folder containing many scripts.
The product page above shows that the price of the item changes if bought in bigger quantities, therefore to validate this in Eggplant, a bespoke function is needed, for example
to calculateQuantityPrice originalPrice, purchaseQuantity
// Set search rectangle to find correct price based on quantity
if purchaseQuantity ...
... is greater than 9 then
set quantityBracket to "tenPlus"
... is greater than 5 then
set quantityBracket to "sixPlus"
... greater than 2 then
set quantityBracket to "threePlus"
// if the quantity is less than 3, then use normal calculation
put (originalPrice * purchaseQuantity) into totalPrice
// read in price for the specific quantity bracket
// calculate the total price and return it
put (the result * purchaseQuantity) into totalPrice
Download The Framework Helper Suite - This Eggplant Suite contains the Common and Config scripts described above to help get you started