如何在Mac OS X下设置RSelenium
Firefox配置文件?
我尝试复制this code(对于Windows),但Firefox一直向我显示下载弹出窗口。
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()
另外on RSelenium developer git repo page还有另一种设置浏览器配置文件的方法
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)
我也尝试过没有成功。
答案 0 :(得分:0)
我遇到了一些与我试图下载的.csv文件类似的问题。同样,我的代码中有browser.helperApps.neverAsk.saveToDisk = "text/csv/xls"))
行。但是,Firefox将这些视为二进制文件。检查下载窗口中的内容,如果您的相似,那么此代码将起作用:
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()
希望有所帮助。