I had to create a test for a report that gives a downloadable file in csv format. The problem is that webdriver will be unable to read the content of the file, because it is not loaded as a webpage, but it will be downloaded as a file in /home/usr/Downloads (probably)
After failing too many times to save and find the report file, I cam with a simple solution:
Send a parameter to the report's endpopint, so it will repond with raw text, instead of returning a csv file.
self.driver.get('url-to-csv-file?download=false') data = self.driver.page_source with open('test-data.csv') as file: testData = json.load(file) self.assertEquals(testData, data)