I am working on a TestCafe script where I capture an endpoint URL that needs to serve as an input for a shell/bash command.
const inputText = await Selector('textarea[name="url-input"]').value;
console.info(`This is my URL of interest ${inputText}`)
Then I want to use inputText
to execute a bash command, say (for simplicity)
echo inputText
How can this be accomplished from my testcafe script? I couldn't find a related post of documentation on this.
I did find a related post on Javascript that uses process.createChildProcess('command');
, but I'm still trying to make this solution work. See docs here
// on declarations
const { exec } = require('child_process');
// inside the test
exec('echo "The \\$HOME variable is $HOME"');