[英]Upload file using Dropzone in Nigthwatchjs
I've a new requirement within my nightwatchjs test script where I need to upload a file within a typical 'Drag or click her to upload' field.我的nightwatchjs测试脚本中有一个新要求,我需要在典型的“拖动或单击她上传”字段中上传文件。
I've not done an upload test before, so I'm after some help please.我之前没有做过上传测试,所以我需要一些帮助。
Below is the html for the field where the files are uploaded too, when manually testing this function;以下是手动测试此功能时上传文件的字段的html;
So, in my nightwatchjs script I currently have the following (taken from an answer given in a previous post here ;所以,在我的 nightwatchjs 脚本中,我目前有以下内容(取自这里上一篇文章中给出的答案;
const path = require('path');
module.exports = {
.....
browser.setValue('input.dz-hidden-input', path.resolve('/path to jpeg/filename.jpeg'));
but this doesn't appear to work.但这似乎不起作用。
It doesn't fail as such (ie there are no error messages, and the test doesn't stop), but the file is not uploaded.它不会因此失败(即没有错误消息,并且测试不会停止),但是文件没有上传。
I thought I might be referencing the wrong element, so I also tried replacing the element input.dz-hidden-input part of the command with;我想我可能引用了错误的元素,所以我也尝试将命令的元素input.dz-hidden-input部分替换为;
but with no luck.但没有运气。
Am I missing something obvious with this test, or is this upload functionality way, way more complicated in nightwatchjs than a simple setvalue command?我是否在这个测试中遗漏了一些明显的东西,或者这种上传功能方式在 nightwatchjs 中是否比简单的 setvalue 命令更复杂?
Any help would be greatly appreciated.任何帮助将不胜感激。
Ok, I've figured this out (through trial and error! :) ).好的,我已经弄清楚了(通过反复试验!:))。
I had the .jpeg directory setup wrong.我的 .jpeg 目录设置错误。
Using the following has worked for me;使用以下对我有用;
browser.setValue('input.dz-hidden-input', require('path').resolve(__dirname + '/harley-davidson.jpeg'));
hope this might help someone else in the future.希望这可能会在将来对其他人有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.