[英]Webdriver io, file upload using input type=“file”
I am writing tests on CoffeeScript using Webdriver.io and mocha .我正在使用Webdriver.io和mocha在CoffeeScript上编写测试。 The code is processed using the CoffeeScript compiler.
使用 CoffeeScript 编译器处理代码。
In the process, I needed to upload a file to the server using the input type = "file" ( display: none ) element.在此过程中,我需要使用input type = "file" ( display: none ) 元素将文件上传到服务器。
I try to transfer the file address as follows (of course, first making it visible: style.display = 'block' ):我尝试如下传输文件地址(当然,首先使其可见: style.display = 'block' ):
elem_input = $('div.class_1 input.class_2')
browser.elementSendKeys(elem_input.elementId, '/home/user/ ... /test.txt')
The file cannot be found, the error message " File not found " appears in the console.找不到文件,控制台出现“找不到文件”的错误信息。
I carefully checked the path, it is correct.我仔细检查了路径,是正确的。 If you upload the file directly through the interface, manually, there are no problems either.
如果直接通过界面上传文件,手动上传,也没有问题。
What could be the reason for this situation and what could be the solutions to the problem?造成这种情况的原因是什么,解决问题的方法是什么?
file_path = browser.uploadFile(FILE_PATH)
# Путь к загружаемому файлу на устройстве
$('div.my_selector').setValue(file_path)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.