Windows popup interaction for downloading using selenium webdriver in python

Viewed 2007

I am making a programme to automatically download the data using selenium webdriver in python. When i click on "download" button following popup occours

.enter image description here

with default option "Open with" selected. I want my program to first click on the option "save file" and then click on "OK". I have used following piece of code to set up Firefox profile

    profile = webdriver.FirefoxProfile()
    profile.set_preference('browser.download.folderList', 2)
    profile.set_preference('browser.download.manager.showWhenStarting', False)
    profile.set_preference('browser.download.dir', os.getcwd())
    profile.set_preference('browser.helperApps.neverAsk.saveToDisk', "application/xlsx")

But it is not working in my case. Then I tried to switch to this window from main window by using following code

    parent_h = driver.current_window_handle
    handles = driver.window_handles
    handles.remove(parent_h)
    driver.switch_to_window(handles.pop())    

But now I am not getting how to interact with this window?

2 Answers
Related