I’ll assume that you’re referring to webdriver and a link within a
browser.
My code is written for Firefox, so you’ll need to modify it for
whichever browser you’re using, but it might give you an idea.
Code:
@profile = Selenium::WebDriver::Firefox::Profile.from_name ‘default’ #Use new if you want a fresh profile rather than your normal one
@profile[‘browser.download.folderList’] = 2 # custom location setting @profile[‘browser.download.dir’] = @download_directory @profile[‘browser.helperApps.neverAsk.saveToDisk’] = “application/pdf,
application/octet-stream, text/xml” #Add the appropriate MIME type here
if you have problems
#Open firefox with your modified profile
@@driver = Watir::Browser.new :firefox, :profile => @profile
I’ll assume that you’re referring to webdriver and a link within a
browser.
My code is written for Firefox, so you’ll need to modify it for
whichever browser you’re using, but it might give you an idea.
Code:
@profile = Selenium::WebDriver::Firefox::Profile.from_name ‘default’
What if I am using IE? or Chrome?
I saw this for chrome but could not find for IE. #Use new if you want a fresh profile rather than your normal one
@profile[‘browser.download.folderList’] = 2 # custom location setting @profile[‘browser.download.dir’] = @download_directory @profile[‘browser.helperApps.neverAsk.saveToDisk’] = “application/pdf,
What will be the name of the downloaded file?
Is there any way to specify/sustomize the name of the downloaded file?
For example the name of the file I want will be id+”.pdf", id is a
variable.
application/octet-stream, text/xml" #Add the appropriate MIME type here
if you have problems
#Open firefox with your modified profile
@@driver = Watir::Browser.new :firefox, :profile => @profile
You’d probably write a separate function to determine the most recent
file, wait for its size to stop changing, and then rename it.
Does latest version of “selenium-webdriver” would support such
autodownload functionality. To achieve this what-else gems we need to
download, exepect ‘selenium-webdriver’.
Your quick help will be appreciated always. I am currently now
developing such a script.
You’d probably write a separate function to determine the most recent
file, wait for its size to stop changing, and then rename it.
Does latest version of “selenium-webdriver” would support such
autodownload functionality. To achieve this what-else gems we need to
download, exepect ‘selenium-webdriver’.
Your quick help will be appreciated always. I am currently now
developing such a script.
Thanks,
Please avoid my last comment. Thank you very much to share this. But
after downloading the window is not closed- talking about the
“Downloadable” window.
How to close that- please advice me. As I need to download 600 files
from the browser with that script.
Okay! Thanks. You are awesome. Okay with “selenium-webdriver” is it
possible to close some pop-up browser which are unwanted, using their
‘titles’ or anything else?
I meant go look up the MIME type of the file you’re having trouble with,
then add that specific one. It’ll help you understand what you’re
dealing with, rather than taking a scattershot approach.
I meant go look up the MIME type of the file you’re having trouble with,
then add that specific one. It’ll help you understand what you’re
dealing with, rather than taking a scattershot approach.
Is it possible to pause the next set of statements until the download is
not being finished?