I'm using Selenium, java and classloader to upload a pdf-file to a HTML-page with the element
type="file"
My code is:
String fileURI = ClassLoader.getSystemResource("file.pdf").getFile();
setText(DOCUMENTATION_FILE_FIELD, fileURI);
public void setText(Locator textField, String text) throws Exception {
HtmlInput htmlInput = (HtmlInput) getElement(textField);
pageUtils.page = (HtmlPage) htmlInput.setValueAttribute(text);
}
When I press the "upload" button on the page, nothing happens. No errors, no file is uploaded.
When I get the text from the DOCUMENTATION_FILE_FIELD
, the correct path is shown.
When googling I read in a forum that it is not possible to automatically upload a file because of security reasons. Is this correct? If this is the case, is there any other ways to do this.