Forum Discussion

jesseejames's avatar
jesseejames
Occasional Contributor
5 months ago

TestComplete Commandline with multiple variables

What's the best way to pass multiple variables in Powershell to run TestComplete commandline
 
$myVariables is a array list which has multiple variables like "XXX=123", "YYY=345", "ZZZ=567"
So I assumed if you need multiple variables in command line, you just add multiple "/pv:xxx=123"
 
 
Start-Process 'C:\Program Files (x86)\SmartBear\TestComplete 15\Bin\TestComplete.exe' -ArgumentList """$TestCompleteFilePath"" /project:""$myTestProjectName"" /test:""$myTestName"" /pv:""$myVariables[0]"" /pv:""$myVariables[1]"" /pv:""$myVariables[2]"" /run "  -Wait

6 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    For example,

     

    $TestCompleteFilePath = "C:\Temp"
    $myTestProjectName = "SmartBear"
    $myTestName = "Hello World"
    $myVariables = @('One', 'Two', 'Three')
    
    Write-Host 'C:\Program Files (x86)\SmartBear\TestComplete 15\Bin\TestComplete.exe' -ArgumentList """$TestCompleteFilePath"" /project:""$myTestProjectName"" /test:""$myTestName"" /pv:"$myVariables[0]" /pv:"$myVariables[1]" /pv:"$myVariables[2]" /run " -Wait

     

    Will output,

     

    PS C:\Users\SmartBear> C:\Temp\Untitled1.ps1
    C:\Program Files (x86)\SmartBear\TestComplete 15\Bin\TestComplete.exe -ArgumentList "C:\Temp" /project:"SmartBear" /test:"Hello World" /pv: One  /pv: Two  /pv: Three  /run  -Wait

     

    When using PowerShell, you need to ensure that your variables are quoted correctly, using either single or double quotes

  • jesseejames's avatar
    jesseejames
    Occasional Contributor

    Thanks I found out the solution

     

    $arrayList = New-Object System.Collections.ArrayList
     

    Here's how you use the array in command


    /pv:$($arrayList[0]) /pv:$($arrayList[1])
    • jesseejames's avatar
      jesseejames
      Occasional Contributor

      Thanks for the feedback, I have tried your version, but not working, so I have to twist a little bit to make it work.

       Why the powershell doesn't like the double quotes? I don't know, it just fails to read the value of variables. but hey at least finally I make it works now yay! 

       

      Start-Process 'C:\Program Files (x86)\SmartBear\TestComplete 15\Bin\TestComplete.exe' -ArgumentList """$TestCompleteFilePath"" /project:""$myTestProjectName"" /test:""$myTestName"" /pv:$($arrayList[0]) /pv:$($arrayList[1]) /run "  -Wait
  • rraghvani's avatar
    rraghvani
    Champion Level 3

    What is not working? I've shown an example using arrays, and the output!