Run In Background

Webtau can run commands in foreground and in background . When command is ran in background webtau will continue execution, leaving command to run its course.To run a command in a background use cli.runInBackground with a single string parameter that includes a command and all its arguments: cli.runInBackground('scripts/sleeps') println "process above may still be running"

Stop Command

Use .stop to explicitly terminate the running background command def command = cli.runInBackground('scripts/sleeps') println "some commands that assume running process" command.stop()

Interacting With Command

We are going to test a "hello world" script that asks you for a name and greet you: #!/bin/bash echo "enter your name" read name echo "hello $name" Use .send to send input to a running command. Use .output.waitTo to wait for command to rich a certain state: def helloWorld = cli.runInBackground("scripts/hello-world") helloWorld.output.waitTo contain("enter your name") helloWorld.send("webtau\n") helloWorld.output.waitTo contain("hello webtau") helloWorld.stop() You can use << instead of .send for extra syntax sugar: def helloWorld = cli.runInBackground("scripts/hello-world") helloWorld.output.waitTo contain("enter your name") helloWorld << "webtau\n" helloWorld.output.waitTo contain("hello webtau") helloWorld.stop()