【发布时间】:2019-06-17 15:25:20
【问题描述】:
我正在编写一个 TestCafe 脚本,在该脚本中我捕获了一个端点 URL,该 URL 需要用作 shell/bash 命令的输入。
const inputText = await Selector('textarea[name="url-input"]').value;
console.info(`This is my URL of interest ${inputText}`)
然后我想使用inputText 来执行一个 bash 命令,比如说(为简单起见)
echo inputText
如何通过我的 testcafe 脚本来实现这一点?我找不到有关此文档的相关帖子。
我确实在 Javascript 上找到了使用 process.createChildProcess('command'); 的相关帖子,但我仍在努力使这个解决方案发挥作用。请参阅文档here
// on declarations
const { exec } = require('child_process');
// inside the test
exec('echo "The \\$HOME variable is $HOME"');
【问题讨论】:
标签: javascript bash automated-tests e2e-testing testcafe