Skip to main content

uploadFile

Overview​

Use the uploadFile command to upload a file to a Selenium Standalone server or to the browser via its driver (e.g., Chromedriver).

warning

The uploadFile command is only supported when using Selenium Grid or Chromedriver. This is because it uses an unofficial protocol feature that is currently implemented only in Chrome and when running on Selenium Grid.

Usage​

await browser.uploadFile(localPath);

Command Parameters​

NameTypeDescription
localPathStringThe path to the local file.

Usage Examples​

const path = require("path");

it("should upload a file", async ({ browser }) => {
await browser.url("https://the-internet.herokuapp.com/upload");

const filePath = "/path/to/some/file.png";
const remoteFilePath = await browser.uploadFile(filePath);

await browser.$("#file-upload").setValue(remoteFilePath);
await browser.$("#file-submit").click();
});

References​

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.