Custom NightwatchJS command for file upload using remote selenium grid
Nightwatch.js 1.6.4 + BrowserStack
This works only for NightwatchJS v1.4+
This project requires adm-zip
npm i adm-zip
- Place the folder customCommands in the root of your project
- Update NightwatchJs Config:
custom_commands_path: ["customCommands"],
module.exports = {
"File Upload Test": (browser) => {
sessionQueue.push({ sessionId: browser.sessionId, GUID: GUID });
setSessionName(browser.sessionId, `${GUID}: test file upload`).then(() => {
browser
.url("https://the-internet.herokuapp.com/upload")
.uploadLocalFile(
"/path/to/file",
'[data-qa="File-Input"]'
)
.click("#file-submit")
.pause(10000)
.end();
});
},
};