File Upload Testing in Nightwatch.js

前端 未结 3 1135
旧巷少年郎
旧巷少年郎 2020-12-05 19:22

I\'d like to reopen the question posed here and here about testing file uploading within Nightwatch.js which uses selenium.

Both links have the recommended solutio

3条回答
  •  半阙折子戏
    2020-12-05 19:43

    In my case, I had an additional problem because the file I was trying to upload was too high up in my directory structure.

    As soon as I moved the file to the same level (or in a subdirectory of) the actual test files, things worked.

    From a script living in my page-objects folder:

    // No dice:
    var fullPath = require('path').resolve(__dirname + '/../../somefile.pdf');
    
    // Works:
    var fullPath = require('path').resolve(__dirname + '/../somefile.pdf');
    
    this.setValue('input#fileUpload', fullPath);
    

提交回复
热议问题