I'm trying to download a file from a website using selenium in Python. I'm using a chrome webdriver to do the following
- I click on the button to download the dataset and add an implicit wait
time.sleep(4)
to wait for the download to begin - Then I select a drop-down for the next data-set.
The problem is that when the file download begins the download bar pops up and the window gets resized. This triggers a javascript code that refreshes the page to fix the UI. Due to this the dropdown selection sometimes occurs before the page is refreshed which causes the code to stop post the refresh.
These are the possible workarounds that I can think of
- Increase the implicit wait time (Inefficient and have to use implicit wait. Cannot wait for an element to be visible because the same page is reloaded with the same elements)
- Disable javascript in the entire webdriver profile (I need it for other elements to load, plus I'm unable to pass arguments to the webdriver due to IT restrictions)
- Download the file in a separate window similar to this answer (Again, inefficient)
- Press
Ctrl
+J
immediately to skip the browser download bar from popping up (Browser shortcuts are not working with the chrome webrowser)
I'm a bit new to automated testing, so any other ideas that you may have would be helpful.