Package: testwizard.test
Testwizard - TestPython language support for testing different kinds of devices using testwizardUsageUse this package in combination with one (or more) of the specific device packagesSidecar fileThe testwizard manager enables a single script to be run on different devices with (optionally) different sets of parameters.
To enable this from any IDE a sidecar file (in json format) is used .
By default the name of the sidecar file is the same as this script, but with a .json extension. If this file is not found default.json in the same folder as the script will be used when available.
A command-line-argument (--sidecar or -s) can be used to instruct the usage of a different file.This json file has the following attributes:tester: The name of the tester (optional)parameters: An array of parameters (optional)name: The name of the parametervalue: The value for the parametercustomProperties: An object holding the custom property values (optional)resources: An array of resourcescategory: The category of the testobjectname: The name of the testobjectid: The id of the testobjectcustomProperties: An object holding the custom property values (optional)outputFolder: The folder where the log files should be written (optional)ParametersEvery parameter will be made available as a field of the session object.param1=session.parameters['param1']ResourcesAll resources will be acquired (and thus locked) at the start of a test run and will be released when the script ends.
To execute a command on a testobject it must be referenced (constructed), when doing this, the name of the resource will be used, while the id corresponds to the actual device.mobile=Mobile(session,"Mobile")result=mobile.initDriver()CustomPropertiesCustom properties are maintained in the Testwizard manager and can be set on Sessions and TestObjects.
These custom properties can be accessed from within a script.sessionProperty=session.customProperties["myString"]testObjectProperty=mobile.customProperties["myNumber"]Output folderWhen running a test all actions are logged (testrun.log) and so is the result (result.log).
By default the location of these files is a timestamp based folder within the runs folder.
If a different location is preferred, this can be configured in the outputfolder attribute.SessionWhen the script is executed (run or debug), a new session is created, and all resources will be locked
If any of the resources is allready in use, a session cannot be setup and an error will be thrown.
The session is destroyed when the script ends. At this point the resources will be released and available for other script runs.More information about the session can be read from the info attribute:infoscriptFilePath: The full path of the script filescriptFileName: The file name of the script filestoragePath: The directory where the output will be writtentester: The name of the testerinfo.environmentscriptsBasePath: The root directory where all scripts are storedstorageBasePath: The root directory where the output is writtenocrEngine: The name of the ocr engine being usedtestWizardVersion: The version of testwizard being usedinfo.session (optional: only when run from within the manager)id: The unique identifier of the session in the managername: The name of the sessionscriptIndex: The index of the script within the sessionResultsThe outcome of a script run can be either Pass, Fail or Error.
During a script run multiple results can be reported, this can be done in 2 different ways:addPass / addFail: reports a pass or fail but does not post it to the serversetResult: reports a pass / fail /error and posts it to the serverresult=mobile.initDriver()ifresult.success:session.addPass(result.message)else:session.addFail(result.message)result=mobile.initDriver()ifresult.success:session.setResult(ResultCodes.PASS,result.message)else:session.setResult(ResultCodes.FAIL,result.message)Sample scriptpython (sample.py)importsysimporttimefromtestwizard.testimportTestWizardfromtestwizard.testimportResultCodesfromtestwizard.mobileimportMobilefromtestwizard.set_top_boximportSetTopBoxwithTestWizard()asTW:session=TW.sessionprint("-- Parameter and Custom properties ---")print("Parameters:")print("  param1 = "+session.parameters.param1)print("  param2 = "+session.parameters['param2'])print("  dummy = "+str(session.parameters.get('dummy')))print("Custom Properties:")print("  myString = "+session.customProperties.myString)print("  myNumber = "+str(session.customProperties['myNumber']))print("  dummy = "+str(session.customProperties.get('dummy')))print("Session info:")print("  info.scriptFilePath = "+session.info.scriptFilePath)print("  info.scriptFileName = "+session.info.scriptFileName)print("  info.storagePath = "+session.info.storagePath)print("  info.tester = "+session.info.tester)print("  info.environment.scriptsBasePath = "+session.info.environment.scriptsBasePath)print("  info.environment.storageBasePath = "+session.info.environment.storageBasePath)print("  info.environment.ocrEngine = "+session.info.environment.ocrEngine)print("  info.environment.testWizardVersion = "+session.info.environment.testWizardVersion)ifsession.info.sessionisnotNone:print("Script was started by the manager:")print("  info.session.id = "+session.info.session.id)print("  info.session.name = "+session.info.session.name)print("  info.session.scriptIndex = "+session.info.session.scriptIndex)print("-- Create Mobile test object ---")mobile=Mobile(session,"Mobile")print("-- Mobile test object info ---")print("  id = "+mobile.info.id)print("  name = "+mobile.info.name)print("  category = "+mobile.info.category)print("  device.serialNo = "+mobile.info.device.serialNo)print("  device.hardwareVersion = "+mobile.info.device.hardwareVersion)print("  device.softwareVersion = "+mobile.info.device.softwareVersion)print("  device.description = "+mobile.info.device.description)print("  device.vendor.name = "+mobile.info.device.vendor.name)print("  device.vendor.modelName = "+mobile.info.device.vendor.modelName)print("  device.vendor.serialNo = "+mobile.info.device.vendor.serialNo)print("Custom Properties:")print("  myString = "+mobile.customProperties.myString)print("  myNumber = "+str(mobile.customProperties['myNumber']))print("  dummy = "+str(mobile.customProperties.get('dummy',None)))print("mobile: initDriver")result=mobile.initDriver()print(result.message)ifresult.successisFalse:session.addFail(result.message)print("-- Create SetTopBox test object ---")setTopBox=SetTopBox(session,"STB")print("stb: sendRCKey")result=setTopBox.sendRCKey("menu")print(result.message)ifresult.successisFalse:session.addFail(result.message)ifnot(session.hasFailsorsession.hasErrors):session.addPass("Test was successful")sidecar file (sample.json){"tester":"Some tester","parameters":[{"name":"param1","value":"value1"},{"name":"param2","value":"value2"}],"customProperties":{"myString":"test","myNumber":123.4},"resources":[{"category":"MOBILE","name":"Mobile","id":"Mobile 1","customProperties":{"myString":"Just testing","myNumber":456}},{"category":"STB","name":"STB","id":"SetTopBox 1"}],"outputFolder":"c:\\temp"}CompatibilityThe version is compatible with testwizard version 3.7LicenseTestwizard licensing