Executing scripts through Batch job using a .vbs file

 

Scenario: Automation scripts will be automatically executed from Windows Scheduler by providing the .vbs file path. The .vbs file contains the code which upon getting triggered from the Scheduler will invoke the test scripts from ALM to execute automatically.

Problem1: While trying to debug the .vbs file, we are unable to connect to ALM from our code so need your help to get connected to ALM from our .vbs file.

 

Dim tdc
Dim runName
On Error Resume next
Set tdc = CreateObject("TDAPIOLE80.TDConnection")


tdc.InitConnectionEx ALM_Path
tdc.Login username, password
tdc.Connect Domain,ProjectName

If (tdc.connected <> True) Then
MsgBox "Unable to connect to ALM project" &"Project"
WScript.Quit
End If

Set tfact = tdc.TestSetFactory
Set tsTreeMgr = tdc.TestSetTreeManager
Set tcTreeMgr = tdc.TreeManager
nPath = TestScript_Path_In_ALM
Set TestSetFolder = tsTreeMgr.NodeByPath(npath)

Set TestSetF = TestSetFolder.TestSetFactory 'Retreive test from given folder in test lab
Set aTestSetArray = TestSetF.NewList("")
tsSet_cnt=aTestSetArray.Count
For i=1 to tsSet_cnt ' Loop through the Test Sets to pick the desired test Set
Set tstests=aTestSetArray.Item(i)
TestSet_Name=tstests.Name
PRINT TestSet_Name
If TestSet_Name= TestSet_Name Then
Flag=1
Set TestCaseF = tstests.TSTestFactory 'Retreive Test Cases from the test set
Set aTestCaseArray = TestCaseF.NewList("")
test_qc_cnt=aTestCaseArray.count
For n=1 to test_qc_cnt
Set ts_obj=aTestCaseArray.item(n)
tname_QC=ts_obj.Test.Name
If tname_QC=TestCase_Name Then
If Flag=1 Then
runName =ts_obj.RunFactory.UniqueRunName
Set RunF = ts_obj.RunFactory ' for managing test runs.
Set theRun = RunF.AddItem(runName)


Set Scheduler = tstests.StartExecution("")
Scheduler.RunAllLocally = True
Scheduler.run
Set execStatus = Scheduler.ExecutionStatus
Do While RunFinished = False

execStatus.RefreshExecStatusInfo "all", True

RunFinished = execStatus.Finished

Set EventsList = execStatus.EventsList

For Each ExecEventInfoObj in EventsList
strNowEvent = ExecEventInfoObj.EventType
Next

For p= 1 to execStatus.count
Set TestExecStatusobj = execStatus.Item(p)
intTestid = TestExecStatusobj.TestInstance
Next
Loop


theRun.Name =runName 'assign a run name
theRun.Status ="Passed" 'value could be parametrized
theRun.CopyDesignSteps
theRun.Post
Flag=0
End If
Set runStepF = theRun.StepFactory
Set aTestStepArray = runStepF.NewList("")
Set runStepF = theRun.StepFactory
Set aTestStepArray = runStepF.NewList("")
step_cnt=aTestStepArray.Count
For j=1 to step_cnt ' Loop through steps and update in qc
Set runStep=aTestStepArray.item(j)
step_QC=runStep.Name
runStep.Status ="Passed" 'value could be parametrized
runStep.Post
Next
End If
Next
Flag=1
End If
Next

Parents
  • Set tdc = CreateObject("TDAPIOLE80.TDConnection")
    
    tdc.InitConnectionEx ALM_Path
    tdc.Login username, password
    tdc.Connect Domain,ProjectName
    
    If (tdc.connected <> True) Then
    MsgBox "Unable to connect to ALM project" &"Project"
    WScript.Quit
    End If

    The above code might not be correct. Instead of that, can you try this?

    Set tdc = CreateObject("TDAPIOLE80.TDConnection")
    
    tdc.InitConnectionEx ALM_Path
    tdc.Login username, password
    tdc.Connect Domain,ProjectName
    
    If tdc.LoggedIn Then
    MsgBox "Unable to connect to ALM project" &"Project"
    WScript.Quit
    End If

    Hopefully that works.

     

    pavan

Reply
  • Set tdc = CreateObject("TDAPIOLE80.TDConnection")
    
    tdc.InitConnectionEx ALM_Path
    tdc.Login username, password
    tdc.Connect Domain,ProjectName
    
    If (tdc.connected <> True) Then
    MsgBox "Unable to connect to ALM project" &"Project"
    WScript.Quit
    End If

    The above code might not be correct. Instead of that, can you try this?

    Set tdc = CreateObject("TDAPIOLE80.TDConnection")
    
    tdc.InitConnectionEx ALM_Path
    tdc.Login username, password
    tdc.Connect Domain,ProjectName
    
    If tdc.LoggedIn Then
    MsgBox "Unable to connect to ALM project" &"Project"
    WScript.Quit
    End If

    Hopefully that works.

     

    pavan

Children