The blog has moved to http://jessehouse.com/ ... Many google searches point here so I am leaving it operational, but there will be no new posts.

Sunday, March 25, 2007

Selenium and file uploads

I have recently started using Selenium for testing web applications; pretty sweet (you know it had to be good coming from ThoughtWorks); anyhow I ran into an issue with testing File uploads; after a couple of Google searches it turns out that Selenium is using javascript requests to manipulate all the html controls and there is a built in security feature (in the browser) that does not allow file uploads to be controlled via javascript. This is probably a real good thing, I sure wouldn't want personal files being randomly uploaded to someone else's web server.

Anyhow if you simply change the browser string to *chrome it will work (at least against localhost, haven't tried it against any of our beta sites yet)

selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.com/");

Read more about chrome and other experimental browser launchers here

More on Selenium
Selenium uses JavaScript and Iframes to embed a test automation engine in your browser. This technique should work with any JavaScript-enabled browser. Because different browsers handle JavaScript somewhat differently, we usually have to tweak the engine to support a wide range of browsers on Windows, Mac OS X and Linux.
- From http://www.openqa.org/selenium-core/

No comments: