-
Notifications
You must be signed in to change notification settings - Fork 1
Data Parameter Placeholders
A data parameter placeholder is a text string enclosed in hashes (eg #USERNAME#) which is replaced by an actual data value when the test is run. Data parameter placeholders provide for the following capabilities:
- centralised test data management
- test data that is common to all tests
- test data used by only some tests
- test scripts that can run with different test data sets
- dynamic data involving sequential or random numbers
The example automated test described on the Home page shows the Excel test script and the generated test script object source file (.script.js).
There is a third JavaScript file that contains a JavaScript dictionary object of test data. This file is generated from a centralised test data spreadsheet [TestData.xlsm] [https://github.com/jenglezou/pasilla/blob/master/data/TestData.xlsm "Click to got to the file").
This section will use the example test, but modified to contain data parameter placeholders.
Original test spreadsheet Example.xlsx:
New version ExampleWithDataParameters.xlsx showing placeholders:

As before, it contains only one sheet called Session1.script.js. The difference between original and the new spreadsheet is that the in new one most of the parameter data has been replace by placeholders in the form #PLACEHOLDER#. For example, the username which was testuser1 is now #USERNAME#.
The generated JavaScript file, ExampleWithDataParameters\Session1.script.js, now contains placeholders. It is shown below along with the original version:
// ORIGINAL VERSION ----------------------------------------------------------------------------------------------
var Session1 = [
[{action:'Example.Start',params:[{browser:'chrome',url:'http://www.Example.com'}]}],
[{action:'Example.Signin',params:[{username:'testuser1',password:'3X4mpl3'}]}],
[{action:'Example.DoSomethingA',params:[{param1:'data1',param2:'data2'}]}],
[{action:'Example.DoSomethingB',params:[{param1:'data1',param2:'data2'}]}],
[{action:'Example.DoSomethingC',params:[{param1:'data1',param2:'data2'}]}],
[{action:'Example.DoSomethingD',params:[{param1:'data1',param2:'data2'}]}],
[{action:'Example.DoSomethingE',params:[{param1:'data1',param2:'data2'}]}],
[{action:'Example.Signout',params:[{none:''}]}],
[{action:'Example.End',params:[{none:''}]}]
];
module.exports = Session1;
// NEW VERSION WITH PLACEHOLDERS --------------------------------------------------------------------------------
var Session1 = [
[{action:'Example.Start',params:[{browser:'chrome',url:'http://www.Example.com'}]}],
[{action:'Example.Signin',params:[{username:'#USERNAME#',password:'#PASSWORD#'}]}],
[{action:'Example.DoSomethingA',params:[{param1:'#DATAITEM1#',param2:'#DATAITEM2#'}]}],
[{action:'Example.DoSomethingB',params:[{param1:'#DATAITEM1#',param2:'#DATAITEM2#'}]}],
[{action:'Example.DoSomethingC',params:[{param1:'#DATAITEM1#',param2:'#DATAITEM2#'}]}],
[{action:'Example.DoSomethingD',params:[{param1:'#DATAITEM1#',param2:'#DATAITEM2#'}]}],
[{action:'Example.DoSomethingE',params:[{param1:'#DATAITEM1#',param2:'#DATAITEM2#'}]}],
[{action:'Example.Signout',params:[{none:''}]}],
[{action:'Example.End',params:[{none:''}]}]
];
module.exports = Session1;Pasilla
Links: Home, [General Concepts](General Concepts), Tutorial - Create a New Test, Data Parameters