0

enter image description hereenter image description hereI am trying to upload file on web page if i try using "SendKeys" method I am getting following error randomly "A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL while attaching file" so I thought instead of sending file path directly to element I should click on button and then try intracting with window element using "DriverContext.Driver.SwitchTo().ActiveElement().SendKeys(PANcopyPath);" method. But element itself is "Input type" therefore i used attached method but it is not working. Please help.

  • Try this - https://stackoverflow.com/questions/61551055/how-to-handle-windows-file-upload-in-net-core-using-selenium/61566075#61566075 - You path need to be the input for the file upload, Then you send keys to the path for the file location. – Dazed May 13 '20 at 14:28

1 Answers1

0

I don't know if I really understand the problem, but I have 2 ideas:

1) Is the file inside your code's folder? that would help a bit to find it insead of using, for example, the desktop path.

2) We need a little bit more of info of the webelements, maybe you are pointing it at a wrong or inconvenient attribute, ex, duplicated classname which it pick the first one and throws an exception.

In my case, I put the file inside the code's folder and just call it's name to avoid tracking paths which I always have problems using.

I hope it helps you somehow.

  • Issue is that instead of clicking on "Browse" button I want to send key press "ENTER".. But its not working and giving attached error. – Ankit Mishra May 13 '20 at 13:21
  • Selenium does not work with windows objects so you can't work with the popup to upload a file. You have to "work behind the scenes" and just send the file path to the upload element. – Dazed May 13 '20 at 14:44
  • I tried sending file path directly like driver.FindElement(By.XPath("XPath of Element")).SendKeys("Path of File"). It woks 50% of times but randomly gives attached(original post in highlighted blue) error. Therefore I am looking for other methods for the same. – Ankit Mishra May 13 '20 at 18:55
  • do you have the html you can post or a link to the page? – Dazed May 13 '20 at 19:41
  • This is HTML of my element – Ankit Mishra May 14 '20 at 12:59