Upload File issue in Microsoft Edge Browser

I have a scenario where I need to click on the Upload CSV File button and insert a filename in EDGE browser.

I am facing the issue as Below:

When I click on the Upload CSV File button the windows control opens up as shown below.
11

When this windows control opens up the Auto IT is not working.

AutoIT Script:

ControlFocus(“Open”,"",“Edit1”)
ControlSetText(“Open”,"",“Edit1”,“C:\Users\Desktop\AutoIT\upload.png”)
ControlClick(“Open”,"",“Button1”)

But If I ran the autoit exe manually works fine in this case.

Even I have tried with sendkeys, it is giving me below error.

Error:

org.openqa.selenium.WebDriverException: The element is not focusable (WARNING: The server did not provide any stacktrace information)

WebElement upload = driver.findElement(By.xpath("//input[@id=“upload”]");

upload.sendKeys(“C:\images\im.png”);

Can you guys help me on this. I need to upload a file in Microsoft edge browser.

Hello @kk_qa_19!

Uploading a file through a browser seems more of a browser feature that many web application use. In the sense that it is a browser feature, it may not need testing. I see your challenge as one in testability. That is, your test requires information from a CSV file.

If the application is designed well, it should not care how the file is presented. Is it possible to isolate the functionality so that the uploading step is not needed? In that manner, you can evaluate the important part of the application functionality separate from browser features.

Joe

1 Like

the way I do this is:

WinWait("[CLASS:#32770]", “”, 20)
ControlFocus(“Open”,"",“Edit1”)
ControlSetText(“Open”,"",“Edit1”, $CmdLine[1])
ControlClick(“Open”,"",“Button1”)

Passing the path & filename via this method:

void ITXUpload()
{
Process cmd = new Process();
cmd.StartInfo.FileName = Hub.GetSupportFile(@“Executables\FileUpload.exe”);
cmd.StartInfo.Arguments = filename;
cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
cmd.StartInfo.CreateNoWindow = true;
cmd.Start();
}