mrkjones
mrkjones

Reputation: 21

File upload with file browse window in Nightwatch

Working on a test script in Nightwatch.js that will test the file upload action on the page. The webpage has a button that opens a file browse window to select the file to upload. I can pass the path and the file name into the browse window but cannot access that window or the "open" button in it to select the file and start the upload. Any ideas?

Upvotes: 2

Views: 1010

Answers (1)

Gokul Muralidharan
Gokul Muralidharan

Reputation: 161

You might do something like this

filePath = process.cwd()+'/uploads/'+ youruploadfile ; assuming process.cwd gives your the current directory the nightwatch is executed

and then set the value (replace by the right element id )

browser.setValue('input[type="file"]',filePath)

Which will set the file you want to upload for that form and you do not require to click and open the file browser dialog as we will have no control over the same via selenium.

Upvotes: 1

Related Questions