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 matches: header.statusCode: actual: 200 <java.lang.Integer> expected: 200 <java.lang.Integer> (194ms) 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 (508ms)

Setting Config Value

Use cfg.url = "http://url" to set base url for experiments. webtau:000> cfg.url = "https://jsonplaceholder.typicode.com" ===> https://jsonplaceholder.typicode.com webtau:000> http.get("/todos/1") > executing HTTP GET https://jsonplaceholder.typicode.com/todos/1 . header.statusCode equals 200 matches: header.statusCode: actual: 200 <java.lang.Integer> expected: 200 <java.lang.Integer> (0ms) 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 (18ms)

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("https://jsonplaceholder.typicode.com") preparing chrome WebDriver > opening https://jsonplaceholder.typicode.com . opened https://jsonplaceholder.typicode.com (251ms) Using element selectors provides additional information in REPL mode to help with exploration webtau:000> $("ul li a") element is found: by css ul li a getText(): Guide getUnderlyingValue(): Guide count: 3