Search code examples
rubyclickselenium-webdrivercucumberwatir-webdriver

Using Cucumber and Ruby to Download File


I've written some Ruby code (connected with Cucumber) that will go to a website and click a file that I'd like to download. The browser I'm using for this is Google Chrome.

Typically, when you go to download a file in Chrome, it doesn't ask for permission. However, when I run the code I made, it says:

"This type of file can harm your computer. Do you want to keep file_name.exe anyway?" It gives 2 options, "keep" or "discard". I have to click keep.

Obviously, you don't want all executables to just start downloading; however, this particular website/file should always be trustworthy.

Is there a command in Ruby or Cucumber that allows you to click the "keep" button automatically? This could just be a general "click at this pixel" or something. Or is there a way to mark a particular website in Chrome as safe. You can't inspect the element because it's not part of the website, but, instead, part of the browser. Preferably without having to download other software.

With this being said, this suggests that if it is possible, it should also be possible to automate an installation (as in clicking next -> next -> etc) for you. Hopefully this is correct?

Thanks in advance.


Solution

  • I actually switched to using Sikuli, which worked pretty well. Thanks for the help, though.