Read Eval Print Loop

WebTau command line tool comes with a REPL mode that stands for 'read-eval-print-loop'. REPL is an established way to perform interactive execution of an API for the purpose of learning or experimenting. The REPL preserves the context of execution and each new command you run can rely on the established context.

Start REPL

To run WebTau in REPL mode run webtau repl webtau:000> 2 + 2 ===> 4 webtau:000> a = 5 ===> 5 webtau:000> a + 3 ===> 8

Experiment With API

Use the REPL to try out various apis like http. , browser. , db. , cli. , etc. webtau:000> http.get("https://jsonplaceholder.typicode.com/todos/1") > executing HTTP GET https://jsonplaceholder.typicode.com/todos/1 . header.statusCode equals 200 (6ms) response (application/json; charset=utf-8): { "userId": 1, "id": 1, "title": "delectus aut autem", "completed": false } . executed HTTP GET https://jsonplaceholder.typicode.com/todos/1 (456ms)

Setting Config Value

Use cfg.url = "http://url" to set base url for experiments. webtau:000> cfg.url = "https://jsonplaceholder.typicode.com" > setting url source: "manual" url: "https://jsonplaceholder.typicode.com" . set url (0ms) "https://jsonplaceholder.typicode.com" webtau:000> http.get("/todos/1") > executing HTTP GET https://jsonplaceholder.typicode.com/todos/1 . header.statusCode equals 200 (1ms) response (application/json; charset=utf-8): { "userId": 1, "id": 1, "title": "delectus aut autem", "completed": false } . executed HTTP GET https://jsonplaceholder.typicode.com/todos/1 (52ms)

Preserving Browser Context

During browser testing the REPL preserves the context of an opened browser, so you can experiment with css selectors and element actions without re-opening the browser and setting the right web app state. webtau:000> browser.open("file:///home/runner/work/webtau/webtau/webtau-cli-testing/src/test/groovy/data/basic.html") > initializing webdriver for chrome . initialized webdriver for chrome (1s 0ms) > opening file:///home/runner/work/webtau/webtau/webtau-cli-testing/src/test/groovy/data/basic.html . opened file:///home/runner/work/webtau/webtau/webtau-cli-testing/src/test/groovy/data/basic.html (46ms) Using element selectors provides additional information in REPL mode to help with exploration webtau:000> $("p") found single element using by css p innerText: hello web page <p>hello web page</p>