/NightwatchJS-Remote-File-Upload

Custom NightwatchJS command for file upload using remote selenium grid (BrowserStack)

Primary LanguageJavaScript

NightwatchJS-Remote-File-Upload

Custom NightwatchJS command for file upload using remote selenium grid

Test Environment

Nightwatch.js 1.6.4 + BrowserStack

Dependencies

This works only for NightwatchJS v1.4+

This project requires adm-zip

npm i adm-zip

Installation

  1. Place the folder customCommands in the root of your project
  2. Update NightwatchJs Config:
  custom_commands_path: ["customCommands"],

Sample Test

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();
    });
  },
};

Ref:

  1. nightwatchjs/nightwatch#890