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
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.
This looks like a job for .... legal tender! It says so right in this tiny ad: