Browser Based Test Harness External Test Case Data

Over the past few days I have been looking at browser based test harnesses with JavaScript to test Web applications. Specifically, I have created proof-of-concept Internet Explorer harnesses to perform HTTP request-response testing, and to perform UI testing. In both situations however I used hard-coded test case input. Over the weekend I took a look at reading external test case data, and writing test case results, from a browser-based harness. Basically there are two approaches available with Internet Explorer. First, you can read or write information on the test host machine. Second, you can read or write information on the Web application server machine. To read or write test data on the test host machine, you can use code along the lines of:
 
var result = document.getElementById(‘TextBox4’);
var fso = new ActiveXObject(‘Scripting.FileSystemObject’);
var infile = fso.OpenTextFile("C:\\testCases.txt", 1);
// etc.
 
If this code is located and executed on the test host, it will look for file testcases.txt on the test host.
To read or write test data on the Web server machine you can create a short ASP script which contains similar code, and then invoke the script from the test host along the lines of:
 
<form method=’post’ action=’readData.asp’ name=’theForm’>
 <input type=’submit’ />
</form>
 
combined with:
 
var f = document.getElementById(‘theForm’);
f.submit();
 
If this code is located and executed on the Web server, it will look for file testcases.txt on the server. There are many alternatives to browser based test harnesses, and I still don’t have a solid grasp of the pros and cons involved, but the approach seems like it may be useful in certain testing scenarios.
This entry was posted in Software Test Automation. Bookmark the permalink.