0

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.

Raunak Thomas
  • 1,393
  • 1
  • 12
  • 28
  • Does the page resize happen every time? If it does, pick an element and wait for it to go stale (signals the page reload), then wait for your dropdown to be visible and continue your test. – JeffC Jun 02 '18 at 14:42
  • press Ctrl + J may solve your problem? – bhupathi turaga Jun 03 '18 at 05:56
  • @JeffC Good idea, I haven't found any inbuilt module in python that has a functionality to wait for it to go stale but [this](http://engineeringquality.blogspot.com/2013/08/ways-of-dealing-with.html) link looks promising. – Raunak Thomas Jun 03 '18 at 11:10
  • 1
    Here it is... https://seleniumhq.github.io/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html#selenium.webdriver.support.expected_conditions.staleness_of – JeffC Jun 03 '18 at 19:35
  • Thanks @JeffC, I forgot about fixing this issue but your solution was what helped me out. Specifically I found [this](https://stackoverflow.com/a/30385843/3625350) answer that helped me out – Raunak Thomas Jun 07 '18 at 07:15

0 Answers0