I created a scheduled task and my cypress script is being run once an hour. But after that I want to execute a python script and pass the result data there.
Run the script and get the "results" as failed or success.
$ cypress run --spec "cypress/integration/myproject/myscript.js"
And pass the "results" data to a python script.
$ python test.py results
How can I do this?
There is a subprocess
module which is able to run external commands, here is the example:
import subprocess
def get_test_output():
filepath = './cypress/integration/myproject/myscript.js'
res = subprocess.run(
['echo', filepath],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
# In your case it will be:
# res = subprocess.run(
# ['cypress', 'run', '--spec', filepath],
# stdout=subprocess.PIPE,
# stderr=subprocess.STDOUT,
# )
return res.stdout.decode()
if __name__ == '__main__':
test_res = get_test_output()
print(test_res)
# => ./cypress/integration/myproject/myscript.js
You could run cypress
in the begining of test.py
and pass results further to needed functions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With