uploadFile

Uploads a file to the Selenium Standalone server or other browser driver (e.g. Chromedriver) by using the file command. Note: that this command is only supported if you use a Selenium Hub or Chromedriver directly.

Note: this command uses an un-offical protocol feature that is currently only supported in Chrome and when running a Selenium Grid.

Usage#
browser.uploadFile(localPath)
Parameters#
NameTypeDetails
localPathStringlocal path to file
Example#
touchAction.js
const path = require('path');
it('should upload a file', function () {
browser.url('https://the-internet.herokuapp.com/upload')
const filePath = '/path/to/some/file.png'
const remoteFilePath = browser.uploadFile(filePath)
$('#file-upload').setValue(remoteFilePath)
$('#file-submit').click()
});