我尝试了下面的代码,但它不起作用。有人可以帮助我了解如何使用量角器中的autoit
上传文件吗?
var path = require('path');
var file = "../Snaptrude/plans/"+filepath+"";
console.log('file path',file)
var filePath = path.resolve(__dirname, file);
// browser.sleep(3000);
element(by.css('input[type="file"]')).sendKeys(filePath);
var path = require('path');
var appRoot = require('app-root-path');
var uploadFile = appRoot + '/path of the file which you want to upload';
var deferred = protractor.promise.defer();
var control = element(by.xpath('you need to take the xpath of uploaded file'));
control.getText().then(function(text) {
if (text == 'filename') {
在此处输入代码console.log("success");
}
如果您正在使用任何 Web 应用程序,您可以使用上述方式上传文件,而无需使用 Autoit。