1

How can handle Window Open File dialog (set file path and import) using javascript (or some other way) in Selenium ?

1
  • 1
    Are you trying to upload a file on a web page? In other words, is there an <input type=‘file’> element on the page somewhere? Commented May 17, 2018 at 12:25

2 Answers 2

7

If you are trying to upload a file, and the page in question uses the standard upload mechanisms provided by HTML, you can do this directly with Selenium itself. The standard HTML mechanism is with an <input type=‘file’> element. Once you’ve found that file upload element on the page, you can use element.sendKeys(“full/path/and/file/name/here”);. This is documented in Step 10 of the algorithm for the Element Send Keys command of the W3C WebDriver Specification, and is used in several file upload tests in the Selenium project’s test code (example).

Sign up to request clarification or add additional context in comments.

Comments

0

//set file path driver.findelelment(By.Xpath("//input[contains(@type,'file')]")).SendKeys(UploadFilePath);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.