<html>
<title>IDP Automated Test</title>
<head>
<script language=vbscript>resizeTo 960,960 : moveto 10,10</script>
<script language="vbscript" type="text/vbscript">
Dim DirName_TestArea
Sub list_TestCases()
text_button_Submit = "<input type=button style='font:bold;border-style:solid;border-color:red;width:100%' value='Click to Run Selected Test Cases' onClick='submit_SelectedCases'>"
text_button_ClearAllCases = "<input type=button value='Clear All Cases' onClick='clear_All_TestCases'>"
text_button_CheckAllCases = "<input type=button value='Select All Cases' onClick='check_All_TestCases'>"
text_to_post = text_button_Submit + "<br><br>" + text_button_ClearAllCases + " " + text_button_CheckAllCases + "<br><br>"
Set objFSO = CreateObject("Scripting.FileSystemObject")
DirName_Current = objFSO.GetAbsolutePathName(".")
'-- Get checkbox ids for all checked test areas
'For Each test_area In document.getElementsByTagName("input")
For Each test_area In document.getElementById("TestAreas").getElementsByTagName("input")
If test_area.type = "checkbox" And test_area.Checked Then
DirName_TestArea = DirName_Current + "\" + test_area.id
For Each objFile in objFSO.GetFolder(DirName_TestArea).Files
filename_full_TestCase = DirName_TestArea + "\" + objFile.Name
filename_TestCase = Replace(objFile.Name, ".rb", "")
If InStr(filename_TestCase, "_DoNotRun_") = 0 Then
text_to_post = text_to_post + "<input type=checkbox name=" + filename_full_TestCase + ">" + filename_TestCase + "<br>"
'-- Don't know why if checked=true not working???
'text_to_post = text_to_post + "<input type=checkbox name=" + filename_full_TestCase + " checked=true>" + filename_TestCase + "<br>"
End If
Next
End If
Next
Set objFSO = Nothing
document.getElementById("TestCases").innerHTML = text_to_post
End Sub
Sub submit_SelectedCases()
'-- Count checked test cases in div TestCases
num_TestCases = 0
For Each test_case In TestCases.getElementsByTagName("input")
If test_case.type = "checkbox" And test_case.Checked Then
num_TestCases = num_TestCases + 1
End If
Next
'-- Prompt for confirmation to run
If num_TestCases = 0 Then
MsgBox("No test case is selected.")
Else
If num_TestCases = 1 Then
text_prompt = CStr(num_TestCases) + " test case is selected. Run?"
Else
text_prompt = CStr(num_TestCases) + " test cases are selected. Run?"
End If
ans_confirm = MsgBox(text_prompt, 1, "Confirm to Run Test Cases")
If ans_confirm = 1 Then
' Create a batch file and write it with lines of running all selected test cases sequentially
Set objFSO = CreateObject("Scripting.FileSystemObject")
DirName_Current = objFSO.GetAbsolutePathName(".")
filename_Batch = DirName_Current + "\runAllTestCases.bat"
Set objBatchFile = objFSO.CreateTextFile(filename_Batch)
For Each test_case In TestCases.getElementsByTagName("input")
If test_case.type = "checkbox" And test_case.Checked Then
objBatchFile.Writeline "start /w ruby " + test_case.name
End If
Next
objBatchFile.Close
Set objBatchFile = Nothing : Set objFSO = Nothing
run_ShellCommand filename_Batch
End If
End If
End Sub
Sub run_ShellCommand(cmd)
Set objShell = createobject("wscript.shell")
objShell.run cmd
Set objShell = nothing
End Sub
Sub manage_Checkboxes_TestAreas(checkAll)
For Each test_case In TestAreas.getElementsByTagName("input")
If test_case.type = "checkbox" Then
test_case.Checked = checkAll
End If
Next
list_TestCases
End Sub
Sub clear_All_TestAreas()
manage_Checkboxes_TestAreas false
End Sub
Sub check_All_TestAreas()
manage_Checkboxes_TestAreas true
End Sub
Sub manage_CheckBoxes_TestCases(checkAll)
For Each test_case In TestCases.getElementsByTagName("input")
If test_case.type = "checkbox" Then
test_case.Checked = checkAll
End If
Next
End Sub
Sub clear_All_TestCases()
manage_CheckBoxes_TestCases false
End Sub
Sub check_All_TestCases()
manage_CheckBoxes_TestCases true
End Sub
</script>
</head>
<body>
<h1> <center>IDP Automated Test</center> </h1>
<script language="VBScript">
document.write "<p align=right>Last modified: " & document.lastModified & "</p>"
</script>
<div id="TestAreas" style="float:left">
<!-- div with list of test areas -->
<h3> Select Test Areas: </h3>
<script language="VBScript">
Set objFSO = CreateObject("Scripting.FileSystemObject")
DirName_Current = objFSO.GetAbsolutePathName(".")
Set objCurrentDir = objFSO.GetFolder(DirName_Current)
text_button_ClearAllCases = "<input type=button value='Clear All Areas' onClick='clear_All_TestAreas()'>"
text_button_CheckAllCases = "<input type=button value='Select All Areas' onClick='check_All_TestAreas()'>"
text_TA = text_button_ClearAllCases + " " + text_button_CheckAllCases + "<br><br>"
For Each objSubDir in objCurrentDir.SubFolders
If InStr(objSubDir.name, "IDP_") > 0 Then
Name_SubDir = objSubDir.name
TestAreaName = Replace(Name_SubDir, "test_cases_", "")
text_TA = text_TA + "<input type=checkbox id=" + TestAreaName + " onclick='list_TestCases()'>" + TestAreaName + "<br>"
End If
Next
document.write text_TA
Set objCurrentDir = Nothing : Set objFSO = Nothing
</script>
</div>
<div id="TestCases" style="float:left; margin:10px; background-color:powderblue; color:blue"> </div>
<!-- Empty div, to be filled with list of test cases -->
</body>
</html>
No comments:
Post a Comment