【问题标题】:how to upload a file using autoit in protractor如何在量角器中使用 autoit 上传文件
【发布时间】:2019-12-09 04:07:16
【问题描述】:

我尝试了下面的代码,但它不起作用。有人可以帮我了解如何在量角器中使用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);

【问题讨论】:

    标签: file-upload jasmine protractor autoit


    【解决方案1】:

    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。

    【讨论】:

    • 嗨 Chetan,我必须将哪些代码放在 if 块中。你能把文件上传的整个代码发给我吗
    猜你喜欢
    • 2016-09-24
    • 2015-07-26
    • 1970-01-01
    • 2017-01-02
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 2014-02-13
    相关资源
    最近更新 更多