Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firefox 4 with watir webdriver:需要使用helperApps.neverAsk在无提示的情况下保存CSV的帮助吗_Firefox_Watir_Webdriver_Firefox4_Watir Webdriver - Fatal编程技术网

Firefox 4 with watir webdriver:需要使用helperApps.neverAsk在无提示的情况下保存CSV的帮助吗

Firefox 4 with watir webdriver:需要使用helperApps.neverAsk在无提示的情况下保存CSV的帮助吗,firefox,watir,webdriver,firefox4,watir-webdriver,Firefox,Watir,Webdriver,Firefox4,Watir Webdriver,我学习了如何将Firefox4与watir和webdriver(在Win7x64上)一起使用,设置配置文件项。例如: profile = Selenium::WebDriver::Firefox::Profile.new profile["browser.download.useDownloadDir"] = true profile["browser.download.dir"] = 'D:\\FirefoxDownloads' profile["browser.helperApps.neve

我学习了如何将Firefox4与watir和webdriver(在Win7x64上)一起使用,设置配置文件项。例如:

profile = Selenium::WebDriver::Firefox::Profile.new
profile["browser.download.useDownloadDir"] = true
profile["browser.download.dir"] = 'D:\\FirefoxDownloads'
profile["browser.helperApps.neverAsk.saveToDisk"] = "application/csv"
driver = Selenium::WebDriver.for :firefox, :profile => profile
browser = Watir::Browser.new(driver)
我尝试使用下面的示例,将CSV文件设置为始终下载到特定目录,而从不打开。 上面的代码成功地设置了所有自动下载到指定目录的文件,但是设置
browser.helperApps.neverAsk.saveToDisk
没有效果:我仍然得到了打开/保存问题。 脚本运行后,Firefox窗口仍然打开,我输入URL about:config。 我可以看到
browser.helperApps.neverAsk.saveToDisk
已正确设置为
application.csv
,但在firefox/options/options/applications中,我看不到csv文件的条目。 似乎真正有效的菜单设置并没有真正与about:config设置绑定。
我做错了什么?

我已经为您做了一些测试,不幸的是CSV文件似乎没有标准的内容类型。您可以尝试传递一个以逗号分隔的内容类型列表,希望其中一个适合您。对我来说,正是应用程序/八位字节流起了作用

require 'watir-webdriver'
require 'selenium-webdriver'

profile = Selenium::WebDriver::Firefox::Profile.new
profile["browser.download.useDownloadDir"] = true
profile["browser.download.dir"] = '/tmp'
profile["browser.helperApps.neverAsk.saveToDisk"] = "text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream"
driver = Selenium::WebDriver.for :firefox, :profile => profile
browser = Watir::Browser.new(driver)

browser.goto "http://altentee.com/test/test.csv"

在Firefox 6+中,如果不专门设置“browser.download.folderList”值,我无法实现此功能:

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.folderList'] = 2 #custom location
profile['browser.download.dir'] = download_directory
profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv, application/csv"
b = Watir::Browser.new :firefox, :profile => profile

请参阅:

有代表做这件事的人可能也应该在这个问题上添加firewatir标签。好吧,这与firewatir gem无关,它不能驱动Firefox 4,也不使用webdriver。啊,好的,对不起,出于某种原因,我以为webdriver是与firewatir一起使用的。谢谢你让我直截了当的回答。不。Firewatir是一个宝石,watir webdriver是另一个宝石。一个不需要另一个。两者都可以驱动Firefox,但firewatir无法驱动Firefox4。。。我的意思是,服务器返回的内容类型可能不是application/csv。。。例如,它可能是text/csv。。。在firebug->net->response Header中仔细检查服务器返回的内容类型是值得的…其中一个有效,我不知道是哪一个。但我会把它们都留下,以防万一有什么变化。考虑到没有一个标准,拥有多种内容类型并没有什么坏处。很高兴它能为您工作……需要的是“text/csv”