Knowledge Base Article

> Knowledge Base > Rapise

Often you want to be able to parameterize your Rapise tests to have a common set of test functions that can use different combinations of test data. You can use a MS-Excel spreadsheet to store the test data and use Rapise to read out the matching values. This articles provides a sample for doing this.

In this example we have a spreadsheet that contains some lookup data:

TestTest Data
Test1valuetest1
Test2valuetest2
Test3valuetest3
Test4valuetest4
Test5valuetest5

We want to dynamically query this Excel sheet and find the test data associated with a specific case. For example if we query for "Test2" we want to return back the test data "valuetest2".

The function that will do this uses the built-in Spreadsheet object:

function FindValueFromFile(filename, valueToFind) 
{
	//Open the spreadsheet
	var success = Spreadsheet.DoAttach(filename, 'Sheet1');
	Tester.Assert('Open Spreadsheet', success);

	//Now loop through and see if we can find that value
	var rowCount = Spreadsheet.GetRowCount();
	Spreadsheet.SetRange(2, rowCount + 1, 1, 2);

	//Loop through all the rows and find the match
	var data = '';
	while (Spreadsheet.DoSequential()) 
	{
		if (Spreadsheet.GetCell(0) == valueToFind)
		{
			data = Spreadsheet.GetCell(1);
		}
	}
	return data;
}

 

Attached to this article is a zipfile containg the complete test project.

Attachments

Selected files will be attached to any email sent on saving ticket.

file selected files selected  () Delete Selected

  • Created:
  • by:

Select files to upload

Or drag and drop files here

Uploading …
Done!
Upload More?
There was an error.
Try again?

Save to upload the selected file(s)

Article Info
  • Last Updated: 6/28/2018
  • Article ID: KB27
  • Views: 5207