Forum Discussion

OV's avatar
OV
Frequent Contributor
3 years ago
Solved

Passing Test Parameters via Command Line won't work

Hi, I'm trying to launch test complete and pass a parameter via command line but, following the instructions from here - https://support.smartbear.com/testcomplete/docs/working-with/automating/comma...
  • OV's avatar
    OV
    3 years ago

    Hi,

     

    Just for the sake of anyone else get into this problem, here is the solution:

     

    def processCommandLineArgument(VersionFromTheApp):
    #iterate through all parameters sent via command line set in Jenkins file
      for i in range (0, BuiltIn.ParamCount()):
        #verify any of tha parameters contain a string called LatestSprintVersionNumber
        if "LatestSprintVersionNumber" in aqConvert.VarToStr(BuiltIn.ParamStr(i)):
          #split the /LatestSprintVersionNumber=x.x.xxxx.xx parameter into 2 bits ('/' 'and LatestSprintVersionNumber=x.x.xxxx.xx')
          items = aqConvert.VarToStr(BuiltIn.ParamStr(i)).split("/")
          #split the LatestSprintVersionNumber=x.x.xxxx.xx parameter into 2 bits ('LatestSprintVersionNumber and 'x.x.xxxx.xx')
          items = aqConvert.VarToStr(items[1]).split("=")
          #check if the first item in position [0] in items array equals to 'LatestSprintVersionNumber'
          if aqConvert.VarToStr(items[0]) == "LatestSprintVersionNumber":
             #check if the value appears in the app in the help-->about window equals to the second item in position [1] in items array
             if VersionFromTheApp == aqConvert.VarToStr(items[1]):
               Log.Message("The latest sprint version passed via the command line is " + aqConvert.VarToStr(items[1]))
               Log.Message("The installed version is " + VersionFromTheApp)
               Log.Message("Both, latest sprint build version and the installed one are the same")
            else:
               Log.Message("The latest sprint version passed via the command line is " + aqConvert.VarToStr(items[1]))
               Log.Message("The installed version is " + VersionFromTheApp)
               Log.Message("The latest sprint build version and the installed one are not the same")