rubywatir

Problem setting default download directory in Watir after update


We recently updated our Watir version from 6.8 to 6.19 in anticipation of the 7.0 beta. Since then, our browser configuration that sets the default directory for chrome has stopped working. Our method that sets it is below.

    def setup

      prefs = {
        download: {
          prompt_for_download: false,
          default_directory: @download_dir
        }
      }

      Watir::Browser.new :chrome, options: { prefs: prefs }
    end

@download_dir is set as the dir that I want and I have confirmed that by checking the value with a breakpoint after prefs has been defined.

As far as I can tell, this is how http://watir.com/guides/chrome/ specifies that you should set this up. This method worked fine before the update. I've tried some of the solutions from similar issues on SO with no success.

I receive no errors as far as I can tell, and our testing suite runs fine other than downloading to the chrome default folder instead.

Thanks in advance!


Solution

  • As mentioned in the comments, this is due to a bug in selenium detailed here github.com/SeleniumHQ/selenium/issues/7917.

    Using strings in the style of "prompt_for_download" => false fixes the problem.