We use Robot Framework to run our tests and we do use the Run command to execute some Powershell scripts to perform some external tasks. This works when we set up the command line parameters in one variable but I'd like to be able to set up the parameters when I execute. Is there a way to configure the run command with extra variables that can be passed to a script? Ideally I'd like to be able to do something like:

run powershell.exe myScript.ps1 -var1 variable1 -var2 variable2

Of course the format will be set as per the Robot framework structure.


You should be able to use something like:

KEYWORDS = "powershell.exe %s %s %s" % (Var1, Var2, Var3)
Run Keywords @{KEYWORDS} 

See the help pages here

You could also use the python extensions to generate and execute the command(s).

  • Thanks that looks like it will do what I want....right now I only need to use 2 or 3 variables specifically but wanted to have an option to add more later on as needed.
    – MichaelF
    Jul 24 '15 at 19:41
  • Can you please explain in details about this command. I am trying to execute the powershell file and once the file executed, i have to provide input and continue till I am get the response. Probably two to three input i have to provide. I am tring to execute in windows machine
    – Ashok
    Dec 14 '17 at 19:55
  • @Ashok you need to ensure that the PS script can run without user inputs providing that all of the required inputs are provided as values &/or flags on the initial command line. This usually involves reading the helps and looking for the required input parameters and flags such as /y in many such programs responds Yes to all user Y/N questions. Alternatively in pythons subprocess calls you can capture stdout & stderr results and push responses to stdin to pretend to be a user. Dec 15 '17 at 6:33
  • Thanks Steve Barnes. I have tried the method you have suggested. I have provided all the values in one line and executed using run process keyword. The script executed successfully. But the command provided is not executed on AUT. If I execute the same manually, its working fine. Can you pls suggest me how to execute the below command in power shell Invoke-RestMethod -Uri $apiUrl -Method POST -Body $jsonrole -ContentType 'application/json' -Headers @{USER_ID='abc123'} -UseDefaultCredentials -DisableKeepAlive -ProxyUseDefaultCredentials All the parameters substitution done perfectly.
    – Ashok
    Dec 15 '17 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.