EJS
EJS

Reputation: 1071

Interact with File Browser Window using javascript

When uploading files to a website you will usually press an upload button which opens up the file browser of the OS you are using. I have a series of automated Selenium tests that runs remotely. Because I'm running the tests remotely I need to do everything through Selenium. One of the ways I'm able to interact with the browser in Selenium is by executing javascripts. Is it possible to create a javascript that will write in the path of the file and then hit enter (or click on OK)? Or is javascript only able to interact with objects in the browser?

Upvotes: 1

Views: 66

Answers (2)

arc
arc

Reputation: 4691

No, this is not possible because of security reasons.

Upvotes: 1

Igal S.
Igal S.

Reputation: 14583

No. You cannot do it. And the reason is security.

If such script would exists, a malicious site could easily upload files from your PC to their server!

Upvotes: 1

Related Questions