Well I know that selenium world is full of file upload threads, and this is something which I came across today and have not been able to solve so far. Though have solved these issues in past by typing in the file input text box of file upload using FF browser.
So first of all there is no file input box. It is just one button which brings a pop up to select a file and as soon as you pick the file, upload begins own its on. html looks as –
<div id="container" style="position: relative;">
<div id="filelist"></div>
<br>
<a id="pickfiles">
<input type="button" name="Photos" value="Pick a File"></a>
<div id="p15tlsibt1185d1pi41tbd16c31a0n0_flash_container" style="position: absolute; top: 21px; background: none repeat scroll 0% 0% transparent; z-index: 99999; width: 86px; height: 18px; left: 0px;" class="plupload flash"><object width="100%" height="100%" data="/CKFinder/upload/content/runtimes/plupload.flash.swf" type="application/x-shockwave-flash" style="outline: 0pt none; background-color: transparent;" id="p15tlsibt1185d1pi41tbd16c31a0n0_flash"><param value="/CKFinder/upload/content/runtimes/plupload.flash.swf" name="movie"><param value="id=p15tlsibt1185d1pi41tbd16c31a0n0" name="flashvars"><param value="transparent" name="wmode"><param value="always" name="allowscriptaccess"></object></div></div>
So I tried using id/name of etc to click but of no avail. I tried clicks like these –
Commons.clickById(webDriver, "pickfiles")
But nothing happens on page.
I also tried – code snippet posted here which uses java script exectuion –
cant click button which opens file attachment dialog
but of no avail. I always encounter error stating –
System.InvalidOperationException : arguments[0].click is not a function (UnexpectedJavaScriptError)
Any Suggestion?
And got the solution using autoit, here is the sample script –
I hope it helps others