Using Python to Run TestStand Sequence File

Updated May 10, 2018

Reported In

Software

  • TestStand

Programming Language

  • Python

Issue Details

Is there a way to call TestStand sequence file and retrieve the test status in a Python script?

Solution

NI TestStand provides a comprehensive ActiveX API, which can be used from any software development environment that supports access to ActiveX automation servers. To achieve this in Python you need to utilize the Pywin32 Python Module. Python Sample Code:

Executing MainSequence:
tsEngine = win32com.client.Dispatch('TestStand.Engine.1')
print('TestStand %s.%s ready' % (tsEngine.MajorVersion, tsEngine.MinorVersion))
sequencePath = 'C:\\Users\\Desktop\\Sequence File 1.seq'
seqFile = tsEngine.GetSequenceFileEx(sequencePath)
execution = tsEngine.NewExecution(seqFile, "MainSequence", None, False, 0)
execution.WaitForEndEx(60000)
print(execution.ResultStatus)
tsEngine.ReleaseSequenceFileEx(seqFile, 0x4)


It is also possible to execute a sequence file with process model and generate a report. Below is the sample code:
 

Executing Single Pass with Sequential Model:
tsEngine = win32com.client.Dispatch('TestStand.Engine.1')
sequencePath = 'C:\\Users\\Desktop\\Sequence File 1.seq'
seqFile = tsEngine.GetSequenceFileEx(​sequencePath)
procModel = tsEngine.GetSequenceFileEx('SequentialModel.seq', 0x20, 1)
execution = tsEngine.NewExecution(seqFile, 'Single Pass', procModel, False, 0)
execution.WaitForEndEx(60000)
print(execution.ResultStatus)
tsEngine.ReleaseSequenceFileEx(procModel)
tsEngine.ReleaseSequenceFileEx(seqFile, 0x4)

 

WAS THIS ARTICLE HELPFUL?

Not Helpful