T
T
Timur Evgazhukov2018-06-19 19:25:34
JavaScript
Timur Evgazhukov, 2018-06-19 19:25:34

How to upload files to website using selenium?

There was a problem with uploading files to the site through selenium. When selenium server and nodejs script are run locally everything works fine, when selenium server is run on a remote Ubuntu server it fails to upload files and no errors occur.
File upload code lines:
let absoluteFilePath = path.resolve(pathFileName);
const uploadElement = await this.client.findElement({ css: `input[name="${elementName}"]` }); // input type="file"
await uploadElement.sendKeys(absoluteFilePath);
The files are taken from the folder (relative to the nodejs project) /public/image/upload
I understand that you need to use setFileDetector or remote.FileDetector, but they do not help. Maybe I'm doing something wrong?
I use firefox
client.setFileDetector(new remote.FileDetector()); // didn't help
or
client.setFileDetector(wd.FileDetector.LocalFileDetector); // doesn't help either

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Evgazhukov, 2018-07-03
@evgajukov

I had to run it locally

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question