Here at Sauce Labs, we work with, quite literally, millions of real-world Selenium tests. A handful of major issues with Selenium come up again and again with our customers. Some are browser configuration details we can tweak in our cloud, while others are beyond the reach of Selenium 1.
The good news for the Selenium community is that Selenium 2 aims to solve these latter issues in a comprehensive way. Most current Selenium users, however, have yet to make the leap to Selenium 2. In the meantime, we’ve been working around some of the biggest issues to make things work well for users of Sauce OnDemand.
Testing with SSL is challenging. Testing with Selenium and SSL can seem downright impossible. But it doesn’t have to be so! Selenium users encounter two major issues with SSL: Selenium’s proxy mode interfering with the SSL connection and invalid certificates in staging environments. The solution to both is to use the Selenium project’s “CyberVillains” Certificate Authority.
In browsers other than Internet Explorer and Firefox, Selenium proxies all HTTP and HTTPS traffic. Browsers correctly recognize that the HTTPS connection is being interfered with and prevent Selenium from doing its job. The solution that the Selenium project came up with is to have Selenium’s proxy server sign HTTPS connections itself, using the CyberVillains CA. Once you install this certificate to the Trusted Root Certificate Authorities on Windows, Selenium can re-sign all HTTPS connections with a certificate signed by CyberVillains, allowing Selenium to drive your browser to HTTPS URLs. By default, it will do its best to validate the certificate used to sign the connection Selenium makes to your AUT, but that, too, can be dealt with.
Many teams use SSL certificates in testing that aren’t entirely valid. This presents a problem for in-browser testing, because browsers will complain about the SSL certificates being invalid on HTTPS URLs. CyberVillains to the rescue again! When browsers are configured to use Selenium to proxy all content, Selenium can be launched with -trustAllSSLCertificates, which turns off Selenium’s SSL certificate validation and accepts anything. In *iexplore and *firefox modes (AKA *iehta and *chrome, respectively), browsers are not configured to use Selenium as a proxy server, which usually means the CyberVillains approach doesn’t work. In Sauce OnDemand, we now automatically configure Internet Explorer to use Selenium as a proxy server, even in *iexplore mode. For Firefox, we’ve implemented custom profiles, which give you even more control over your certificate environment.
You can read more about our HTTPS support in the Sauce OnDemand documentation.
We have now enabled full Unicode support for all browsers in Sauce OnDemand. We’ve installed East Asian Language support on all of our Windows robots, so your Unicode will render correctly in screenshots/videos, and you can now make assertions in your tests using unicode characters.
Cross-browser File Upload
File upload has been a persistent problem for Selenium users. We are excited to announce our preliminary support for cross-browser file upload in Sauce OnDemand. We’ve stepped out of the browser environment to interact directly with the operating system (only Windows for now), downloading files you specify from a URL and entering them into file input fields. We have this working on all versions of Internet Explorer, Safari, and Firefox on Windows, and we look forward to open-sourcing our work when we’ve flushed out the last few issues with it.
We’ve implemented file upload support using the existing attachFile command in Selenium, so you don’t even need to change your tests that already work in Firefox. Just call attachFile with a URL to the file you want uploaded and a Selenium locator for the file input box, and we’ll take care of the rest!
OS-level Popup Eliminator
Using the same OS-level hooks we built for cross-browser file upload, we’ve built a popup eliminator that will automatically click “OK” or “Yes” in any browser-level popups that appear in Internet Explorer. For example, even with the CyberVillains certificate, IE 6, 7, and 8 will pop up warnings when opening a page with mixed HTTP/HTTPS content. Our popup eliminator takes care of these and more popups. As we gain confidence in this approach, we look forward to pushing these changes upstream into the Selenium project or open-sourcing them as a standalone wrapper for Selenium.
At Sauce Labs, we’re all about providing the best Selenium experience possible. If you have suggestions for how we could improve these features, let us know on our forums!