我想上传与NightwatchJS图像,但设置值输入不起作用。我正在使用DropzoneJS作为上传部分。模拟一个文件上传(DropzoneJS)与NightwatchJS
我已经尝试从溶液: NIghtwatch.js File Upload with Dropzone.js
HTML
<input type="file" multiple="multiple" style="visibility: hidden;
position: absolute; top: 0px; left: 0px; height: 0px; width: 0px;">
的JavaScript
module.exports = {
"Upload test": function(browser) {
browser
.url('localhost:8080')
.assert.elementPresent('form > div:nth-of-type(2) > div > div:nth-of-type(3) > div:nth-of-type(2) > div > input')
.execute('document.querySelectorAll("input[type=file]")[0].style.display = "block";')
.setValue('form > div:nth-of-type(2) > div > div:nth-of-type(3) > div:nth-of-type(2) > div > input', require('path').resolve(__dirname + '/img.jpg'))
.assert.valueContains('form > div:nth-of-type(2) > div > div:nth-of-type(3) > div:nth-of-type(2) > div > input', require('path').resolve(__dirname + '/img.jpg'))
.end();
}
}
Nightwatch正在截图时,测试失败,然后将截图表明我没有上前广告任何东西,这就是为什么最后的断言失败。