RSelenium:设置用于Mac OS X的makeFirefoxProfile以下载文件而无需询问 [英] RSelenium: Setting makeFirefoxProfile for Mac OS X to download files without asking
问题描述
如何在Mac OS X下设置RSelenium
Firefox配置文件?
How should I set RSelenium
Firefox profile under Mac OS X?
我试图复制此代码(适用于Windows),但是Firefox不断向我显示下载弹出窗口.
I tried to replicate this code (for Windows) but Firefox keeps showing me the download popup.
require(RSelenium)
my_firefox_profile <- makeFirefoxProfile(
list(browser.download.dir = "~/Downloads/tmp",
browser.download.folderList = "2",
browser.download.manager.showWhenStarting = "false",
browser.helperApps.neverAsk.saveToDisk = "text/csv/xls"))
RSelenium::startServer()
remDr <- remoteDriver(extraCapabilities = my_firefox_profile)
remDr$open()
remDr$navigate('http://www.rapidtables.com/web/html/link/html-download-link.htm')
webElem <- remDr$findElement(using = 'xpath', "//*[@id='doc']/p[6]/a")
webElem$clickElement()
remDr$close()
remDr$closeServer()
也在RSelenium开发人员git repo页面上,还有另一种设置浏览器配置文件的方法
Also on RSelenium developer git repo page there's an additional way to set the browser profile
extraCapabilities <- list("browser" = "IE",
"browser_version" = "7.0",
"os" = "Windows",
"os_version" = "XP",
"browserstack.debug" = "true")
remDr <- remoteDriver$new(remoteServerAddr = ip, port = port
, extraCapabilities = extraCapabilities)
我也尝试了但没有成功.
which I also tried with no success.
推荐答案
我尝试下载的某些.csv文件有类似的问题.同样,我的代码中有browser.helperApps.neverAsk.saveToDisk = "text/csv/xls"))
行.但是,Firefox将它们视为二进制文件.检查下载窗口上的内容,如果您的内容与之相似,则此代码将起作用:
I had a similar problem with some .csv files that I was trying to download. Similarly, I had the line browser.helperApps.neverAsk.saveToDisk = "text/csv/xls"))
in my code. However, Firefox saw these as binary files. Check what it says on the download window, if yours are similar then this code will work:
fprof <- makeFirefoxProfile(list(browser.download.dir = [YOUR DOWNLOAD FOLDER],
browser.download.folderList = 2L,
browser.download.manager.showWhenStarting=FALSE,
browser.helperApps.neverAsk.saveToDisk = "application/octet-stream"))
remDr <- remoteDriver(extraCapabilities=fprof)
remDr$open()
希望有帮助.
这篇关于RSelenium:设置用于Mac OS X的makeFirefoxProfile以下载文件而无需询问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!