WebdriverIO:如何 运行 文件上传 AutoIt .exe 脚本
WebdriverIO: How to run file-uploading AutoIt .exe script
我正在使用 WebdriverIO to run a file-uploading .exe
created with AutoIt。
我正在 运行 将脚本放入 browser.execute
命令中。该文件需要从本地驱动器 运行 并在 Chrome 浏览器中执行 wd。
这是代码:
this.open("https://smallpdf.com/word-to-pdf");
this.SubmitClick("//div[@class='l0v3m7-3 hIetmU']");
this.BrowserSleep(2000);
scr.runAutoItScript('C:\test\desktopApp\autoit', 'fileUpload.exe')
//scr have the child process:
const { execFile } = require('child_process').execFile;
module.exports = {
runAutoItScript(pathToScript, scriptName) {
console.info(`\n> Started execution of ${pathToScript} / ${scriptName} ...`);
execFile(`${pathToScript}/${scriptName}`, (error, stdout, stderr) => {
if (error) {
throw error;
} else {
console.info(`\n> Finished execution of ${scriptName}! | Output: ${stdout}`);
}
});
}
}
我记得以前做过类似的事情,我使用了 NodeJS 的 child_process.execFile 命令。文档内容很重 child_process,请仔细阅读。
你最终应该得到如下内容:
const execFile = require('child_process').execFile;
let runAutoItScript = function(pathToScript, scriptName) {
console.info(`\n> Started execution of ${scriptName} ...`);
execFile(`${pathToScript}/${scriptName}`, (error, stdout, stderr) => {
if (error) {
throw error;
} else {
// > do something with the script output <
console.info(`\n> Finished execution of ${scriptName}! | Output: ${stdout}`);
}
});
}
runAutoItScript('/this/is/a/valid/path', 'AwesomeScript.exe');
下一步是缩小它并在 browser.execute
调用中使其 运行。
您可以在网上找到很多 child_process 示例,只需利用可用资源即可 运行 最简单的脚本。从那里发展。
我正在使用 WebdriverIO to run a file-uploading .exe
created with AutoIt。
我正在 运行 将脚本放入 browser.execute
命令中。该文件需要从本地驱动器 运行 并在 Chrome 浏览器中执行 wd。
这是代码:
this.open("https://smallpdf.com/word-to-pdf");
this.SubmitClick("//div[@class='l0v3m7-3 hIetmU']");
this.BrowserSleep(2000);
scr.runAutoItScript('C:\test\desktopApp\autoit', 'fileUpload.exe')
//scr have the child process:
const { execFile } = require('child_process').execFile;
module.exports = {
runAutoItScript(pathToScript, scriptName) {
console.info(`\n> Started execution of ${pathToScript} / ${scriptName} ...`);
execFile(`${pathToScript}/${scriptName}`, (error, stdout, stderr) => {
if (error) {
throw error;
} else {
console.info(`\n> Finished execution of ${scriptName}! | Output: ${stdout}`);
}
});
}
}
我记得以前做过类似的事情,我使用了 NodeJS 的 child_process.execFile 命令。文档内容很重 child_process,请仔细阅读。
你最终应该得到如下内容:
const execFile = require('child_process').execFile;
let runAutoItScript = function(pathToScript, scriptName) {
console.info(`\n> Started execution of ${scriptName} ...`);
execFile(`${pathToScript}/${scriptName}`, (error, stdout, stderr) => {
if (error) {
throw error;
} else {
// > do something with the script output <
console.info(`\n> Finished execution of ${scriptName}! | Output: ${stdout}`);
}
});
}
runAutoItScript('/this/is/a/valid/path', 'AwesomeScript.exe');
下一步是缩小它并在 browser.execute
调用中使其 运行。
您可以在网上找到很多 child_process 示例,只需利用可用资源即可 运行 最简单的脚本。从那里发展。