• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File upload using selenium (selenium-java-2.15.0.jar) not working

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,
I wrote a java code to connect to a site and after navigating to few pages try to upload a file.
But whenever I am trying to upload a file it gives the message "File upload failed. Please close the file and try again" in the driver.getPageSource() output . Is it like the website not allowing the file upload and sends this message back or its some selenium restriction on file upload.
Few important points- 1. The actual website only runs in IE
2. When I created my own dummy code in servlet/jsp for file upload and use the same selenium code then it worked
Please help


 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Soumyajit,


Which WebDriver implementation are you using (i.e. the headless HTML Driver or the InternetExplorer driver?)

The way you describe using the getSource leads me to believe you are using the HTML driver and as such can not see for yourself what is happening. I am just beginning to work with the InternetExplorerDriver implementation itself (I typically use firefox), but what I can say is that most of my "debugging" of similar issues is performed by setting a breakpoint in the code right before the error or even at the beginning of the test and watching the browser as the various steps are "painted" in the UI and performed.

If everything "looks" ok when you do this, then the next step is to inspect the HTML as you are seeing in the driver window. It is possible that there is more than one element matching the "id" used and you are firing an event that does not make sense. Sometimes these buttons are activated/deactivated based on checkboxes, etc and could be hidden in multiple frames, etc. If this is the case, you may need to look at finding the element using XPath so you can put some additional qualifications on the conditions to find the element.

The fact that your dummy JSP works unfortunately does not mean much unless the dummy code renders the exact code (HTML, javascript, etc) that the target sight does and otherwise behaves the same way. One additional trick I have used is to capture the true HTML and put it into a local JSP as you describe so that I can at least test against a local copy and avoid the internet traffic but this is more of a convenience aspect than anything.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic