Is it possible to download files to the test machine during a grid test?

3,279 views
Skip to first unread message

Tony Belfiore

unread,
Aug 24, 2016, 9:12:54 AM8/24/16
to Selenium Users

I have a Selenium Grid with nodes set up for my automated testing (on windows machines). I have successfully used the LocalFileDetector approach when I have tests (.NET Selenium v2.53.1) that need toupload files (from my test/build machine to the node).


I was wondering if it was possible to download files from my Grid node to my test machine - similar to LocalFileDetector for uploads. I would really like my test logic/machine to verify the file that was downloaded.


What is the recommended approach for such scenarios?

Any advice would be greatly appreciated.


Thanks.


--Tony

⇜Krishnan Mahadevan⇝

unread,
Aug 24, 2016, 9:19:58 AM8/24/16
to Selenium Users
Tony,
No there is no such thing that is available in the Grid infrastructure that lets you do this. 
But Mark collins had written up a very elaborate article on downloading with selenium.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/59708175-d796-4cec-82be-6431fdc13646%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tony Belfiore

unread,
Aug 24, 2016, 10:51:36 AM8/24/16
to Selenium Users
I did read his great article.

However, it is critical we are able to download a file and validate its contents.

I did see his "FileDownloader" class, but I wasn't sure if that would help me as (a) we are working in .NET, and (b) it wasn't clear to me that FileDownloader would actually put the downloaded file on the test machine like LocalFileDetector. 

Is there a FileDownloader-like solution out there somewhere to try for .NET? 
Or am I stuck with writing my own custom solution?

Mark makes great points about avoiding downloads, but I'm sure there are a lot of people in the same boat as myself, and I'm surprised something better doesn't exist.



On Wednesday, August 24, 2016 at 9:19:58 AM UTC-4, Krishnan wrote:
Tony,
No there is no such thing that is available in the Grid infrastructure that lets you do this. 
But Mark collins had written up a very elaborate article on downloading with selenium.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Aug 24, 2016 at 6:21 PM, Tony Belfiore <abel...@gmail.com> wrote:

I have a Selenium Grid with nodes set up for my automated testing (on windows machines). I have successfully used the LocalFileDetector approach when I have tests (.NET Selenium v2.53.1) that need toupload files (from my test/build machine to the node).


I was wondering if it was possible to download files from my Grid node to my test machine - similar to LocalFileDetector for uploads. I would really like my test logic/machine to verify the file that was downloaded.


What is the recommended approach for such scenarios?

Any advice would be greatly appreciated.


Thanks.


--Tony

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

⇜Krishnan Mahadevan⇝

unread,
Aug 24, 2016, 10:56:46 AM8/24/16
to Selenium Users
Tony,

I am not aware of any .NET solutions [ I am a Java guy too ]. So you may have to handcraft a similar one for your usage.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cf31f2d3-dd7f-447b-9a49-f46021911b5b%40googlegroups.com.

David

unread,
Aug 24, 2016, 1:05:19 PM8/24/16
to Selenium Users
Mark's solution should (in theory) save the file to the test machine that's executing the test code, not the browser node running the Selenium commands.

I don't know of any public .NET implementations for Mark's method, but while it takes some work to build, it's fairly trivial to do. Just craft a method to use HTTP request/response classes for the respective language platform, pass in a "session" cookie if needed, save the response as bytes to file. Would be nice if someone did share their implementation to the public.

I did find Mark's implementation a bit bloated just to use as a library for file downloads as there's more nice abstraction than needed. I just needed a simple method/class to download a file. So here's an alternative implementation that's more basic and easier to port for .NET I'd think: https://gist.github.com/daluu/4411221

I also made a variant in PHP, so that shows you it's a fairly trivial task to do: https://gist.github.com/daluu/3433180. Did PHP first when we were using Selenium RC with it, and did the Java one when we migrated to WebDriver with Java.

Anand

unread,
Aug 25, 2016, 2:01:58 PM8/25/16
to seleniu...@googlegroups.com
you can point the download path of nodes to the ftp server

Chome Preference/Options in webdriver  are having option to set the default download path for the node which should be ftp server path which hub and nodes can access


On Wed, Aug 24, 2016 at 6:21 PM, Tony Belfiore <abel...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

David

unread,
Aug 26, 2016, 3:07:28 PM8/26/16
to Selenium Users
Thanks for that tip Anand. Is it only for Chrome? What about FF, Safari, IE?


On Thursday, August 25, 2016 at 11:01:58 AM UTC-7, Anand wrote:
you can point the download path of nodes to the ftp server

Chome Preference/Options in webdriver  are having option to set the default download path for the node which should be ftp server path which hub and nodes can access

On Wed, Aug 24, 2016 at 6:21 PM, Tony Belfiore <abel...@gmail.com> wrote:

I have a Selenium Grid with nodes set up for my automated testing (on windows machines). I have successfully used the LocalFileDetector approach when I have tests (.NET Selenium v2.53.1) that need toupload files (from my test/build machine to the node).


I was wondering if it was possible to download files from my Grid node to my test machine - similar to LocalFileDetector for uploads. I would really like my test logic/machine to verify the file that was downloaded.


What is the recommended approach for such scenarios?

Any advice would be greatly appreciated.


Thanks.


--Tony

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Tony Belfiore

unread,
Sep 9, 2016, 8:24:20 AM9/9/16
to Selenium Users
Thanks for the comments everyone. I'm still looking into this issue.

Our current strategy is to have the grid Nodes download files to a Shared Folder on the network. This same folder is also accessible by the test machine, so the test logic can retrieve the downloaded file and verify its contents.

A few issues though:

* We'd like each individual test to dump its downloaded file into a unique sub-directory in the Shared Folder. This way tests won't interfere with each other if they use the same file names. Ideally we would use the SessionId from the RemoteWebDriver as the subdirectory name. However, this won't work because the "download directory" setting in the options (e.g. ChromeOptions, FirefoxProfile) must be set *before* we instantiate the RemoteWebDriver and get the SessionId. Anyone have an idea how to solve this riddle (other than creating my own unique testId)?

* I just realized that IE does not support a "download directory" in the InternetExplorerOptions class, so there is no programmatic way to set the sub-directory under the Shared Folder. So, I guess IE is a dead end for anyone trying to do what we are doing?

--Tony

David

unread,
Sep 9, 2016, 6:23:26 PM9/9/16
to Selenium Users
If you set download directory, I think you can't set the download file name, it's auto-generated/default what the browser uses? I don't know as I've not use that feature myself. If you can set the filename on download, you can just make that unique for each browser/node and that would solve your problem - similar uniqueness separation as unique subdirectories.

But I would think for your specific case, you're better off using the Mark Collins approach to achieve cross browser testing support and be able to use unique subdirectories, etc. You have full control with Mark's approach. Why use the native browser feature when it's restrictive? You're not testing the browser functionality/compatibility specifically but rather your app/site with respect to the download file so you shouldn't be required to test the browser's native file download.
Reply all
Reply to author
Forward
0 new messages