Writing Python Selenium test results to a file
python, selenium
Solution
Tests results output is writen to `stderr`. Try
python test.py 2> file
Problem
I'm working on generating a report for a suite of test cases written in Python using Selenium WebDriver. I'm kicking the test cases off with a main script, and I want to write the results to a .txt file that will eventually be sent out in an email. When a test successfully runs, I get something like this in the terminal: ``` ---------------------------------------------------------------------- Ran 1 test in 15.566s OK ``` This ^^^ is what I want to write to a file. I've tried ``` python test.py > file ``` to no avail. I've also tried ``` sys.stdout = open('Results.txt', 'w') ``` which hasn't worked. I just want to write to a file that the test passed or failed, but it just won't print that part. I know it's something internal with the Selenium code, but I can't figure out where/what it is. Any other printing within the test will write to the file, but not the result. Thanks for any advice!!