|
This works in Selenium IDE and/or Selenium RC running in *chrome mode. I should add that except for Selenium IDE and/or Selenium RC, we really have no leads on this at all... it's a security restriction baked into JavaScript itself. There's no clever way to workaround it within pure JavaScript, so it really can't be fixed in Selenium Core. Christian Theune's workaround is described here: http://forums.openqa.org/thread.jspa?messageID=1368#1368 It's basically the same thing as going into *chrome mode. Note that here at my work our trick to workaround this on other browsers was to focus on the file input field and send keystroke events to it using OS-level tools. (Selenium RC could use java.awt.Robot, for example.) Selenium RC could do this, but Selenium Core certainly couldn't. Selenium Core could use java.awt.Robot if we compile and bundle a self-signed applet with Core. The user would have to approve the applet at least once with Core... Or install our certificate before running tests... Hi Dan, Can you elaborate on the workaround for entering data into a filed whose type=file. Regards I have found a work around that involve running in the HTA. This method works about 97% of the time so it is not perfect. before this method can work you need to make sure that the input box has input focus. I would like to have another method for this, but this will for for the mean time. Selenium.prototype.doSendKeys = function(windowname, keys) { catch(w) { throw new Error( 'sendkey did something' + w ); } objShell = null; Just a stupid suggestion: except for selenium IDE, testing using selenium makes it act as a layer between tested site and browser. The job of selenium server is to inject javascript in response to handle selenium testing. A typical testing using selenium is like this for a textfield: selenium.type("form:url", "http://www.google.test"); This will make server instruct browser to do those 2 manipulation in javascript (type something then click something) byte[] datas = ....; This would be crossbrowser compatible, wouldn't need to circumvent javascript securities (this is done selenium server side, not javascript side) and wouldn't need some files at specific location on testing machine (the file uploaded could be randomly generated by unit test driving selenium, or loaded from a database of tests of whatever). Disadvantage: wouldn't work on selenium IDE, as it would require a selenium server to do the injection operation. But would work with any selenium client available (java, php, ...) as long as client implement this additional method. To be clear on my previous post, the idea is to have selenium server not only alter response by injecting javascript in it, but also to alter multipart request, by inject uploaded file in it. So for file uploads, testing woudl'nt be done from javascript but at submit time. Woudln't be perfect but could at least test behaviour of server facing a file upload. (Wouldn't help testing client's reaction to selecting a file however) Dear David Wing, I saw you previous post. The sendKeys command seems to be working but I´m not being able to make sure that the input box has input focus. Who are you setting the focus to the input box? Thanks, |
||||||||||||||||||||||||||||||||||||||
This mail was sent by Christian Theune outlining a workaround on Mozilla:
http://lists.public.thoughtworks.org/pipermail/selenium-users/2005-March/000213.html