chooseFile

Given a selector corresponding to an <input type=file> chooseFile will upload the local file to the browser machine and fill the form accordingly. It does not submit the form for you. This command only works for desktop browser.

Usage

1
browser.chooseFile(selector,localPath);

Parameters

Param Type Details
selector String input element
localPath String local path to file to be uploaded

Example

call.js
1
2
3
4
5
6
7
8
it('uploads a file and fills the form with it', async function () {
var toUpload = path.join(__dirname, '..', '..', 'fixtures', 'cat-to-upload.gif')

browser.chooseFile('#upload-test', toUpload)

var val = browser.getValue('#upload-test')
expect(/cat\-to\-upload\.gif$/.test(val)).to.be.equal(true)
})

Uses