History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SRC-386
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Jason Huggins
Reporter: Jason Huggins
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Selenium Remote Control

Add "attachFile" method to API for handling file input fields.

Created: 12/Nov/07 03:50 PM   Updated: 18/Nov/08 06:45 AM
Component/s: Server
Affects Version/s: 0.9.2
Fix Version/s: 1.0 beta 1

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: Firefox - all platforms


 Description  « Hide
File upload is already supported in Firefox with *chrome mode. Here, we're extending this support to grid environments. Before a file can be set in the input field of a web form, Selenium RC may need to transfer the file to the local machine before attaching the file to a web page form. This is common in selenium grid (aka "hub and spoke") configurations where the remote control driving the browser is not the same machine that started the test.

Supported Browsers: Firefox ("*chrome") only. Other browser supported later.

Usage:
    selenium.attachFile("<locator_of_file_element_on_page>", "<file_URL>")

Example:
    selenium.attachFile("id=file_attachment_field", "http://www.bigcorp.com/~employee1/myfile.jpg")

Selenium RC on the local machine will download the file from <file_URL>, save the file to a temp directory, and then set the file element locator to the correct path. Once the session ends, the temp file will be deleted from the local system.

There are certainly other methods for transferring the file: 1) shared network drive via either NFS or WebDav, or 2) FTP. But for simple cases, this works well, since we know the Remote Control machine will have access to port 80. If the user exposes the file to be downloaded on a public (or intranet) web server, transferring the file to the machine is as simple as GETing the file's URL and saving the stream to disk.

 All   Comments   Work Log   Change History      Sort Order: