Skip to content

General Concepts

John edited this page Mar 25, 2015 · 7 revisions

#Test Script ##JavaScript test script The Pasilla test script that is actually "executed" at run-time is a JavaScript array of objects, like this:

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;

##Spreadsheet test script Creating and maintaining files in this JavaScript format may be considered a bit too much like programming for some users. Users are likely to be more comfortable with designing their test scripts using Excel. So an Excel test script format has been developed from which the JavaScript test scripts can be generated. The test script above was, in fact, generated from the following spreadsheet.

Example.xlsx.PNG

###Sheet format The format of a test script spreadsheet is fairly rigid. Here are the main "rules":

  • the sheet (tab) name must end with ".script.js". The JavaScript generator tool will only process sheets that are named this way.
  • the first row is ignored. It is used to indicate that column B is the "action" column and column C and subsequent columns are for data parameters.
  • from row two onwards the spreadsheet consists of "heading" rows and "test step" rows
  • a heading row is one that does not have an action - its column B is blank. Columns C, D and so on contain headings which are used as parameter names. There can be a variable number of parameter names but there should not be any gaps. The parameter names will be used as JavaScript property names so their case and spelling is IMPORTANT.
  • a test step row contains an action in column B and parameter values in columns C, D and so on. The parameter values correspond to the parameter names and can be blank.
  • multiple test step rows can follow a heading row. This helps to keep things succinct and readable. A heading row applies to all subsequent test step rows until the next heading row is encountered.
  • the use of explicit parameter names (and values) means they can be specified in any order.
  • column A is the "skip" column and can be used to "skip" a test step. If column A of a test step contains any value then the test step will be skipped. It has no effect on heading rows.

###Multiple sheets The spreadsheet format supports multiple test scripts in one Excel file. Each sheet name must end with ".script.js". The support for multiple sheets offers some flexibility to how they can be used in test scenarios.

  • Convenience (for test organisation and maintenance). An excel file can be used to maintain a set of test scripts. It can contain a set of test script that share common data parameters.
  • Sequential execution. Sheets can be named such that Protractor will execute them in the desired order.
  • Concurrent execution. Tests can simply be run in parallel to minimise overall running time. In more complex test scenarios, tests can be run in parallel to represent, for example, concurrent user sessions and interactions.

The JavaScript generation utility [GenerateScriptnProJS.hta] (https://github.com/jenglezou/pasilla/blob/master/utilities) creates a folder corresponding to the Excel file name (tests/Example in this case). It then creates a .script.js and a .pro.js for each sheet in the Excel file.

Clone this wiki locally