this is my first post and sorry for asking the same question once again. I am stuck with a issue regarding uploading a file in Selenium Web Driver. I have searched a lot in this forum but the solutions are not working for me. The element which is the file Browse button is embedded in the file text area ( i.e. where the path of the file gets printed after the browsing through file browse dialog box), but the upload button is separate.
The entire element code is:
<input class="iceInpFileTxt" type="file" size="35" name="upload">
I am unable to click on the "browse" button using click() method. I have tried using Autoit/Robot also.
The code of the element from JSP page:
<ice:inputFile id="fileUpload" width="600" autoUpload="true"
value="#{practitionerLoadDataBean.inputFile}"
actionListener="#{practitionerLoadControllerBean.browse}"/>
I know the input type is file so sendkeys() should work. The codes I have been trying are:
WebElement elem = driver.findElement(By.xpath("//input[@name='upload']"));
elem.sendKeys("<PATH>");
The error message shows as:
org.openqa.selenium.remote.ErrorHandler$UnknownServerException:Unable to locate element: {"method":"xpath","selector":"//input[@name='upload']"}
Please let me know where I my mistake is. Thanks in advance.