Solved
Forum Discussion
- chiragverma123Contributor
This problem is now resolved. Using the following script:
def cmdArray2 = ["python", "C:/Users/Desktop/SOAPProject/test.py"]
def process = new ProcessBuilder(cmdArray2).redirectErrorStream(true).start()
process.inputStream.eachLine {
log.warn(it)
}
process.waitFor()
return process.exitValue()- rupert_andersonValued Contributor
Nice one! :-)
- nmrao
Champion Level 2
But you already seemed to be using selenium / groovy. Why too may approached are being choosen?
If required, you may run it execute command from groovy.
"cmd /c echo hello".execute()
Similarly you can call python with the script name as argument. Give it a shot.- chiragverma123Contributor
nmrao, I am looking for more options since I am struggling with (selenium + SOAPUI.) Please see here - https://community.smartbear.com/t5/SoapUI-Open-Source/Unable-to-run-selenium-code-from-grrovy-script-SOAPUI/m-p/130711#M22365
- rupert_andersonValued Contributor
Hi,
Either of these two approaches might help:
def cmdArray1 = ["python", "-c", "print('hello')"] def cmd1 = cmdArray1.execute() cmd1.waitForOrKill(1000) log.info cmd1.text def cmdArray2 = ["python", "/Users/test/temp/hello.py"] def cmd2 = cmdArray2.execute() cmd2.waitForOrKill(1000) log.info cmd2.text
Where hello.py is:
print "Hello World!"
Let me know how you get on.
Regards,
Rupert