當我點擊網頁的Firefox瀏覽器中使用Ruby的Watir的鏈接:如何在使用watir單擊鏈接時在Firefox中處理下載警報?
ie.input(:id, "c_ImageButton_Text").click
的.text
文件開始下載,然後一個警報,這存在:「我應該做的Firefox與此文件」。我想禁用此警報。
當我點擊網頁的Firefox瀏覽器中使用Ruby的Watir的鏈接:如何在使用watir單擊鏈接時在Firefox中處理下載警報?
ie.input(:id, "c_ImageButton_Text").click
的.text
文件開始下載,然後一個警報,這存在:「我應該做的Firefox與此文件」。我想禁用此警報。
嘗試將配置文件設置爲始終下載特定的文件類型。這是通過設置browser.helperApps.neverAsk.saveToDisk
屬性完成的。
例如,要隨時下載PDF:
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.helperApps.neverAsk.saveToDisk'] = "application/pdf"
b = Watir::Browser.new :firefox, :profile => profile
該物業是逗號分隔的MIME類型的列表。有關如何確定適用的MIME類型的詳細信息,請參閱Scott Alister的文章「Determining file MIME types to autosave using Firefox & Watir-WebDriver」。
請注意,配置此設置與轉至Firefox的選項>應用程序選項卡的用戶相同,該選項允許指定每種文件類型的操作。
我試圖成功地官高的解決方案,這就是工作的優良me..I假設你的情況,你試圖爲擴展名爲.txt ..for這case..solution將是這樣的:
總是下載該文本:
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv"
b = Watir::Browser.new :firefox, :profile => profile
它不工作,警報在那裏。 – unknownbits