Company
Date Published
Author
Isaac Murchie
Word count
588
Language
English
Hacker News points
None

Summary

Selenium WebDriver's PHP bindings have a limitation when it comes to remote file uploads. When running tests on a different machine than the test programs, the files specified for upload are not available to the browser. Selenium 2 solves this problem by providing a method to upload the file to the server and then giving the page the remote path of the file. This functionality is exposed in some language bindings but not in PHP, until it was added to Sausage, allowing for remote testing on Sauce Labs Selenium 2 Cloud. To facilitate remote testing, a function called `fileDetector` is used to determine if a string should be interpreted as the name of a file. If the function returns true, the system transparently reads the file, encodes it in Base64, and sends it to the Selenium server, putting the remote path into the file upload form element instead of the local one. This allows tests to proceed without trouble.