0

I am using MSHTML in automation IE. One of my requirements is to upload a file, and I am able to click the Browse button using the click() method HTMLInputElement.

However, after calling click(), the program does not exit the said method and it is seemingly stuck there indefinitely, unless I manually handle the File Upload popup.

Is there a fix to this or is there an alternative way to upload files using MSHTML?

Here is my code below:

HTMLInputElement browseFile = (HTMLInputElement)cimsDocument.getElementById("file");
browseFile.click(); //my program does not exit from this method
SendKeys.SendWait(@"C:\Users\Test\Desktop\FileToUpload.zip");
thecodeexplorer
  • 363
  • 1
  • 6
  • 18
  • According to your code, it seems that you are using the Windows Forms Webbrowser control with Automation. After clicking the file control, it will display the File Upload Popup, and the original web form is inactive status, unless you manually handle the popup modal and close it. Since, this issue is related to Windows Forms, I suggest you could post this problem on [Windows Forms forum](https://social.msdn.microsoft.com/Forums/windows/en-US/home?category=windowsforms). – Zhi Lv Aug 28 '19 at 09:42
  • As far as I know, if we want to automation IE browser, we could use [selenium IE Webderiver](https://docs.seleniumhq.org/download/), after click the file control and displaying the File Upload Popup, we could use the driver.switch_to.alert to switch to the File Upload Popup, then using Sendkeys method to enter values and click the Ok or Select button to upload the file and close the Popup. – Zhi Lv Aug 28 '19 at 09:50

0 Answers0