1

I want to test (using selenium webdriver) if clicking a button causes the right file download dialog to appear. For the automated part of the test I don't have to download the actual file, checking the filename and the window title would be enough.

At a first glance, I see no way to get this OS-specific dialog box. Do you know a way?

The two questions selenium wget download file and How to download a file using Selenium's WebDriver? are the opposite of my question -- I need the dialog, not the file.

Edit/Clarification: The system under test has a button to download a file which gets saved with the native OS dialog, and the default filename in the dialog is set from the header in the server response.

  • Automated API test: Call the server, examine the header.
  • Manual (full) GUI test: Klick the button, save the file, examine the filename and the contents.
  • Automated (limited) GUI test: Klick the button, examine the filename, abort.

The third bullet point is the one I'm asking about.

o.m.
  • 450
  • 2
  • 7
  • 1
    Just wondering, why do you want to test the OS file dialog? Don't you trust operating system vendors? :) – Niels van Reijmersdal Jun 17 '15 at 17:20
  • Can't you just check the hyperlink itself for the correct filename? – FDM Jun 18 '15 at 05:45
  • @FDM, all I'm seeing from the DOM is a javascript function. I want to test if it gives the right result. – o.m. Jul 17 '15 at 05:23
  • @o.m. In that case, you can also execute javascript with Selenium. It will allow you to call and verify the javascript function. – FDM Jul 17 '15 at 19:37

2 Answers2

1

I had this same problem but our tests were limited for Windows OS, so we designed a simple AutoIT script for it which would return exit code = 0 (if popup was detected) or 1 (if not detected).

This error code was checked within the selenium test script itself.

George
  • 21
  • 1
0

I managed to achieve this, but it is a bit complicated.

You can't automate the OS specific download dialog, if you could that would be a huge security hole.

What I did was to get the computer running the selenium test to pretend to be the client (I was using a selenium grid) and download the file and then check the contents.

To pretend to be the client I had to :

  • on the server, make a copy of the "http only" cookies and send them as part of the page with the download button (pre-pending with 'download-test' to give them a unique name)
  • then use selenium to extract these values
  • craft a request for the download url, adding the extracted cookies
  • check the contents of the downloaded file

So it's not a complete real world test, but it's pretty close.

Bigwave
  • 266
  • 1
  • 4