Wednesday, 13 February 2008

Pairwise test case design part two

I got a request to share the code for the "web shell", which I mentioned in earlier post.

I did a fast translation from Swedish to English and here is the result (please read PICT help file for proper format of the input file):

<html>
<!--
************************************************************************************
Purpose: To generate testcase file.
Assumptions: Proper security settings in browser
Inputs: Inputfile, Outputfile
Returns: Formated XLS Outputfile
Author: Stefan Thelenius 2007-01-09.
'***********************************************************************************
-->
<head>
<title>Create PairWise Test Cases</title>
<SCRIPT LANGUAGE="vbscript">
Sub CreateTest
strInputFile = frmForm1.txtC.Value
strOutputFile = frmForm1.txtB.Value
frmForm1.Ptxt.Value = CreateTestCase(strInputFile, strOutputFile)
End Sub
Function CreateTestCase(strInputFile, strOutputFile)
'Set path to PICT program
strPath = "cmd /K C:\Program\Pict\pict.exe "
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
'Copy input file to temp file
fso.CopyFile strInPutFile, "c:\temp.txt"
Dim oShell
Set oShell = CreateObject ("Wscript.shell")
'Run PICT
Set oExec = oShell.Exec(strPath & "c:\temp.txt > c:\Testfall.xls")
Set oExec = Nothing
Set oShell = Nothing
strCall = "FormatXLFile(""" & strOutputFile & """)"
kaka = setTimeout (strCall,10000,"VBScript")
Set fso = Nothing
CreateTestCase = "Creating file, please wait..."
End Function
Function FormatXLFile(strOutputFile)
Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Workbooks.Close
'Open file created by PICT
ExcelObj.Workbooks.Open "c:\Testfall.xls"
Set NewSheet = ExcelObj.Sheets.Item(1)
NewSheet.Activate
'Format
NewSheet.Rows(1).Font.Bold = True
NewSheet.Columns("A:AA").AutoFit
ExcelObj.ActiveWorkbook.Saved = True
NewSheet.Copy
'Save to output files
ExcelObj.ActiveWorkbook.SaveAs strOutputFile
ExcelObj.ActiveWorkbook.Saved = True
ExcelObj.Application.Quit
Set NewSheet = Nothing
Set ExcelObj = Nothing
Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Workbooks.Close
ExcelObj.Workbooks.Open strOutputFile
ExcelObj.Application.Visible = True
FormatXLFile = "Ready"
Set fso = CreateObject("Scripting.FileSystemObject")
'Delete temp files
fso.DeleteFile("c:\temp.txt")
fso.DeleteFile("c:\Testfall.xls")
Set fso = Nothing
frmForm1.Ptxt.Value = "File ready"
End Function

</SCRIPT>
</head>
<body>
<BODY BGCOLOR="white">
<FONT FACE="verdana" SIZE=1>
<FORM NAME="frmForm1">
<table width="300" border="0" cellspacing="0" cellpadding="0" align="left">
<FONT FACE="verdana" SIZE=1>
<tr>
<td><H3><Center>Create test cases<Center/></H3>
<FONT FACE="verdana" SIZE=1>
Input File syntax: [infilename.txt]<br />
Output File syntax: [outfilename.xls]<br />
</td>
</tr>
</table>
<br><br><br><br><br><br>
<table width="300" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>
<Left>
<FONT FACE="verdana" SIZE=1>
Infile
</Left>
</td>
<td>
<INPUT TYPE="file" NAME="txtC" SIZE=40>
</td>
</tr>
<tr>
<td>
<Left>
<FONT FACE="verdana" SIZE=1>
Outfile
</Left>
</td>
<td>
<INPUT TYPE="file" NAME="txtB" SIZE=40>
</td>
</tr>
<tr>
<td>
<Center>
<FONT FACE="verdana" SIZE=1>
<INPUT TYPE="button" NAME="cmdCalc" VALUE="Create file" onclick="CreateTest">
</Center>
</td>
<td>
<INPUT TYPE="text" NAME="Ptxt" SIZE=40></td>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
</td>
</tr>
</table>
</FORM>
</body>
</html>

6 comments:

Bj Rollison said...

Hi Stefan,

This is a very cool example of how to wrap the PICT tool with a GUI interface. I am glad you visited my blog earlier and left a post, otherwise I might have never found your blog. I look forward to more posts!

- Bj -

Stefan said...

Thanks!

Will said...

Thanks for posting this code. It is going to be useful for me.

Stefan said...

You're welcome. I've got some good QTP stuff from Software Inquisition in the past...

Stefan said...

From an e-mail request:

"I saw a post of your from March/08 saying that you use PICT with a Web GUI on tp of it. Can you point to a place where I can download such a GUI interface."

Answer: Copy the HTML code from this post and save to an HTML-file (please note that there are some hardcoded file paths)

/Stefan

aparna john said...

Hi,Website ranking refers to the given order of Web Design Cochin in the different search engines. Website ranking is important because it helps you to know whether your website will receive any visitors.Thanks.....