2

I have implemented a method for uploading a file to a read-only input field. But when press the OK button, the attachment is Null. Interface Developed by using EXTjs.

public void uploadMyFile(String locatorId, String filePath) {

    WebElement fileInput = findElementExplicitWaitWithNoVisbility(By.id(locatorId), true);

    ((JavascriptExecutor) driverProvider.get()).executeScript(
            "arguments[0].removeAttribute('readonly','readonly')",fileInput);

    fileInput.clear();
    fileInput.sendKeys(filePath);
}
bfontaine
  • 18,169
  • 13
  • 73
  • 107
Padmasankha
  • 103
  • 1
  • 13
  • 1
    Apparentrly you press ok, quicker than the file is uploaded. Try to wait a little bit, and then press ok. – Dmitry Malinovsky Nov 16 '15 at 09:21
  • 1
    Thank you @DmitryMalinovsky. But I found a another issue. I removed read only attribute using firebug. Then copy and paste the path into input field. (Path is definitely correct) When I clicked the ok button attachment was null. – Padmasankha Nov 17 '15 at 04:52
  • try answer available at: http://stackoverflow.com/questions/32760330/how-to-handle-file-upload-in-selenium-in-windows-7/32775165#32775165 – Pankaj Kumar Katiyar Nov 19 '15 at 12:14

0 Answers0