As a part of my test , i want to download a pdf file from browser automatically as soon as it loads on browser. Can someone guide me how this can be achieved.Following is the way that i have tried.I have tried clicking the download button but it didn't work for me. Following is the screenshot that appears on browser .
*** Test Cases ***
Download and deploy content package
${output}= Run keyword job history
Log to console ${output}
# create unique folder
${now} Get Time epoch
${download directory} Join Path ${OUTPUT DIR} downloads_${now}
Create Directory ${download directory}
${chrome options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
${prefs} Create Dictionary prompt_for_download=false download.default_directory=${download directory}
Call Method ${chrome options} add_experimental_option prefs ${prefs}
Create Webdriver Chrome chrome_options=${chrome options}
Goto ${output}
Sleep 5
Although above answer is good but for me following code worked.
I have quite simple workaround for file downloads. It has following rules:
Create download folder in suite setup
Clear the folder on test teardown
With above, you'll be easily able to manipulate downloaded files.