For those that don’t know i left my position in Microsoft to go work for the startup that powers www.georiot.com. Because of this i have gotten in touch with a lot of tools that i had not used for awhile.
This post is my experience of coming back to Selenium from a 6 month Hiatus. This time i used it with the C# webdrivers library and ran it using the firefox browser.
- I feel like the API has improved and getting a simple prototype of my automation took a manner of minutes.
- The firefox profile class is completely straightforward.
- The support for ghostjs and the possibility of running headless is pretty awesome.
- Multiplatform support.
- C# drivers in Mono are kind of finicky(repo linked on the bottom fixes the zip dependency by moving from Ionic to Sharp Zip).
- The User group in google groups does not get has many responses has i hope.
To talk a bit about my task i wanted to login in to a website an click a link to download a file. This was trivial after figuring the firefox profile. The profile below does the following configures Firefox to save & download files to a certain place without asking for confirmation.
var profile = new FirefoxProfile();
profile.SetPreference(“browser.download.folderList”, 2); // This item tells firefox to use a specific directory instead of default
profile.SetPreference(“browser.download.dir”, DownloadFolder); //The specific directory to download
profile.SetPreference(“browser.helperApps.alwaysAsk.force”, false); // Tells firefox to not ask what you want to do with a file
profile.SetPreference(“browser.download.manager.showWhenStarting”, false); // Indicates that the download window should be off
“text/xml, text/csv, text/plain, text/log, application/zlib, application/x-gzip, application/x-compressed, application/x-gtar, multipart/x-gzip, application/tgz, application/gnutar, application/x-tar, application/gzip”); // specifies all the extensions that should be auto download.
Definition of this items can be found at http://kb.mozillazine.org/About:config_entries
Thanks to free_at_last from reddit for helping me improve the article and the concise line to summarize the code.
My problems came when i started trying to run on mono using firefox at first like i mentioned i got an error that said path not found that i traced to this issue. Basically the library does not handle the paths in linux.
I resolved that issue by switching the zipping library and placed the code for it here:
After that firefox would open but then i got into the socket error problem tried installing and older version of firefox and posting into the user group but no solution. (Note also tried it with the ghostjs drivers and they really don’t run in linux with mono). For the meanwhile im going to use a windows box to get me around.
So in summary great new API mono supports seems to be a bit lacking but is an open source project so it could be me that takes the mantle to resolve it on that.