0

I have a file upload scenario where i need to enter the file name. Its a windows based file upload pop up. Send keys or window handles wont work as selenium does not recognize it. Other than using Auto IT is there any other way enter image description here

enter image description here

When an image is uploaded the following tag will be generated [![enter image description here][3]][3]

user4391664
  • 157
  • 1
  • 2
  • 12

1 Answers1

1

This has been answered a few times on here but here is what you need to do. Find the input for the file upload and use send keys to the file path. You do not interact with the ui file upload dialog box.

ex:

        string filePath = "c:\Files\file.png";
        driver.FindElement(By.XPath("//input[@type='file']")).SendKeys(filePath);
Dazed
  • 1,527
  • 1
  • 13
  • 25
  • i am not able to recognize the input for the file upload its a complete windows pop.I already tried send keys its not working – user4391664 Jan 28 '21 at 23:30
  • post the html for the upload. Many times the markup contains an input id = "file". Remember, you are not clicking the upload button. You just need the input where the file goes. I posted a more detailed answer here - https://stackoverflow.com/questions/61551055/how-to-handle-windows-file-upload-in-net-core-using-selenium/61566075#61566075 – Dazed Jan 29 '21 at 00:42
  • WebDriver.FindElement(By.Id("upload-drop-zone-drag-drop-browse")).SendKeys("C:/Image.png"); – user4391664 Feb 01 '21 at 08:53