1 ' |
|
2 ' WScript that will invoke the test run execute functionality at ATS3 web server without installing any ATS3 |
|
3 ' specific programs on the local PC. |
|
4 ' |
|
5 ' Password must be given in encrypted format and the path to test drop must be in URLEncoded |
|
6 ' |
|
7 ' Usage cscript wshRunX.vbs <username> <password> <server hostname> <path to testDrop.zip> |
|
8 ' |
|
9 |
|
10 ' Get the command line arguments |
|
11 set args = WScript.Arguments |
|
12 |
|
13 ' Check that all arguments have been specified |
|
14 Set objShell = WScript.CreateObject("WScript.Shell") |
|
15 Set env = objShell.Environment("Process") |
|
16 checkEnvVars(env) |
|
17 |
|
18 ' Invoke the web application and write the result to stdOut |
|
19 WScript.StdOut.Write doTestRunX(env("ats3.username"), env("ats3.password"), env("ats3.host"), URLEncode( env("ats3.pathToDrop") ), URLEncode( env("ats3.schedule") )) |
|
20 |
|
21 ' Quit the script |
|
22 Wscript.Quit |
|
23 |
|
24 Function checkEnvVars(env) |
|
25 if env("ats3.username") = "" then |
|
26 WScript.Echo "Environment variable ats3.username not specified" |
|
27 WScript.Quit 1 |
|
28 elseif env("ats3.password") = "" then |
|
29 WScript.Echo "Environment variable ats3.password not specified" |
|
30 WScript.Quit 1 |
|
31 elseif env("ats3.host") = "" then |
|
32 WScript.Echo "Environment variable ats3.host not specified" |
|
33 WScript.Quit 1 |
|
34 elseif env("ats3.pathToDrop") = "" then |
|
35 WScript.Echo "Environment variable ats3.pathToDrop not specified" |
|
36 WScript.Quit 1 |
|
37 end if |
|
38 End Function |
|
39 |
|
40 ' Invoke the ATS3 web application in given host with the specified username, password and file path |
|
41 Function doTestRunX(uname, password, hostName, pathToDrop, schedule) |
|
42 On Error Resume Next |
|
43 |
|
44 'If the given hostname contain port, use it otherwise use the default 8080 |
|
45 if(InStr(1, hostName, ":", VBTEXTCOMPARE) = 0) then |
|
46 hostName = hostName & ":8080" |
|
47 end if |
|
48 |
|
49 Set objxmlHTTP = CreateObject("Microsoft.XMLHTTP") |
|
50 Call objxmlHTTP.open("GET", "http://" & hostName & "/ats3/XTestRunExecute.do?username=" & uname & "&password=" & password & "&testrunpath=" & pathToDrop & "&schedule=" & schedule, False) |
|
51 objxmlHTTP.Send() |
|
52 If Err.Number <> 0 Then |
|
53 WScript.Echo "Error sending data to server: " + hostName |
|
54 WScript.Quit 1 |
|
55 End if |
|
56 |
|
57 if objxmlHTTP.status = 200 then |
|
58 doTestRunX = objxmlHTTP.ResponseText |
|
59 else |
|
60 WScript.Echo "Error importing test run: " + objxmlHTTP.ResponseText |
|
61 WScript.Quit 1 |
|
62 end if |
|
63 End Function |
|
64 |
|
65 Function URLEncode(data) |
|
66 data = replace(data,"\","/") |
|
67 data = replace(data,"$","%24") |
|
68 data = replace(data,"&","%26") |
|
69 data = replace(data,"+","%2B") |
|
70 data = replace(data,",","%2C") |
|
71 data = replace(data,"/","%2F") |
|
72 data = replace(data,":","%3A") |
|
73 data = replace(data,";","%3B") |
|
74 data = replace(data,"=","%3D") |
|
75 data = replace(data,"?","%3F") |
|
76 data = replace(data,"@","%40") |
|
77 URLEncode = data |
|
78 End Function |
|