1

I am trying to test uploading a file to a site in chrome but when the upload file button is pressed it automatically opens the windows file prompt. I need to be able to close the upload file prompt in the case when a file is not uploaded. Is there a way to either prevent this prompt from appearing in the first place, or close it after it opens? I cannot use the java robot, it does not work on the system that this test will be run on.

Ayy3
  • 11
  • 2
  • Could you please elaborate the html tags you are interacting with? – deokyong song Mar 01 '22 at 05:45
  • File upload/download dialog belong to OS, not to browser. That's why it's unreachable to selenium or any similar tech. You have to avoid the dialog, upload the file using `element.sendKeys(String filePath);`. Just need locate the right element. See https://www.guru99.com/upload-download-file-selenium-webdriver.html – pburgr Mar 01 '22 at 06:38
  • @pburgr I'm able to find the file upload element and I've been using element.sendKeys(), the issue is that when I send the file to the file element, it doesn't upload until I press the upload button, and when I click on the upload button, the file uploads, but also simultaneously opens the upload dialog. Since I cant close the dialog with selenium, is there a way to prevent it from opening in the first place? – Ayy3 Mar 01 '22 at 15:42
  • Can you share URL? – pburgr Mar 02 '22 at 06:35
  • Inspect the page source code before and after manual file upload to see what changed. Simulate just the final change not the whole process. – pburgr Mar 02 '22 at 06:38

1 Answers1

1

File Upload is usually handled via Sendkeys(FilePath(with Extension)) to the Input Tag.

Rakesh
  • 118
  • 1
  • 9