Disable chrome download multiple files confirmation

后端 未结 9 1423
太阳男子
太阳男子 2020-12-02 01:57

I developed a crawler with ruby watir-webdriver that downloads some files from a page. My problem is that when I click to download the second file, Chrome opens a bar in the

9条回答
  •  星月不相逢
    2020-12-02 02:20

    It seems that the solution is different for older and newer chromedriver versions and that is adding to the confusion.

    chromedriver

    profile = Selenium::WebDriver::Chrome::Profile.new
    profile['download.prompt_for_download'] = false
    profile['download.default_directory'] = download_directory
    
    b = Watir::Browser.new :chrome, :profile => profile
    

    chromedriver2

    prefs = {
          'profile' => {
              'default_content_settings' => {'multiple-automatic-downloads' => 1},
          }
      }
    
    b = Watir::Browser.new :chrome, :prefs => prefs
    

    Today most people are probably using chromedriver2 version and that is a solution that should work fine. It worked ok in my watir scripts as I am not getting the message: "This site is attempting to download multiple files. Do you want to allow this?" anymore.

提交回复
热议问题