Skip to content

User Guide

Peter Thomas edited this page Nov 9, 2023 · 54 revisions

Karate Xplorer makes calling HTTP APIs easy and fun - and you can chain multiple calls to tell a story.

One of the highlights is how you can view JSON as an easy-to-read grid. Karate Xplorer is a great way to show-off what your APIs can do to business users. You can also view payloads as raw-text, with syntax-coloring.

Both Request and Response are shown side by side for convenience. You can add user-friendly labels to each API call for even better readability. Scripting support allows you to scale from simple hard-coded requests to dynamic URLs, headers and payloads and un-limited chaining.

The application runs locally - which means that all your data is secure, you can test APIs that run on localhost or within your network, and you won't be blocked by CORS restrictions.

image

Installing

Download the ZIP file corresponding to your OS from here: v0.1.0-SNAPSHOT.

Right now versions for Mac (darwin) and Windows (win32-x64) are available. If you need a version not yet supported, please contact us.

Extract the ZIP into a directory of your choice. Windows users can directly click on start.bat. Windows may show a warning message, but accept the error and proceed. Mac users can open a terminal in the karate-xplorer folder and run ./start.

By default the web-app starts on port 8080. You can go to this URL to start using Karate Xplorer: http://localhost:8080.

If the application does not start because port 8080 is in use, you can change the port by passing a number as a command-line argument. Windows users can open a cmd window, change directory to karate-xplorer and do this to use port 9000: start 9000.

Mac users can do this: ./start 9000.

Click on Load / Save on the top menu-bar to experience built-in samples that show you the power of Karate Xplorer.

Simple Requests

Click on Run (to run all requests) or the ⏯️ play button to step through the calls one at a time. You can set the URL, Path and HTTP Method. The body can edited as plain-text, and there is syntax support for JSON.

image

Chaining

Chaining can be done by directly referring to specific parts of the previous response. This can be done using expressions in this form: ${response.body.someName}.

For example, here we use a value from the previous response as a path parameter. The placeholder-substitution system uses the "dollar" and "curly braces" convention, for example: ${foo}

image

Placeholders

Placeholder substitution is supported for all the following:

URL | Path | Body | Headers | Params

Examples of how you can dynamically set headers are shown below:

image

Header manipulation is essential for getting past many authorization schemes.

Here below are examples of how to shape query parameters:

image

Advanced Scripting

You can "save" data that persists for the whole sequence. This is commonly needed to perform CRUD via REST-ful HTTP calls.

For example you can use the After section to evaluate expressions. These are small snippets of simple JavaScript. Here we save id and booking for future reference. Note that the booking comes from the request ! This avoids the need for extensive cut-and-paste and can save you a lot of time.

image

JSON Manipulation

Here we are updating JSON by evaluating an expression. We change one value within the booking payload in the Before section.

image

JSON Re-Use

Karate Xplorer has a short-cut to insert a variable into a payload or anywhere expressions are supported.

  • If an expression is enclosed in round-brackets, it will be converted to JSON at run-time.
  • The expression has to begin and end with round-brackets

This is most commonly used to set the Request:Body.

See how easy it is to re-use a variable that happens to be JSON. Look at the Body below set to (booking).

image

Embedded Expressions

Coming Soon, support for Karate-style JSON templating via variable substitution - for e.g. { foo: '#(bar)' }

Global Variables

You can add multiple variables that will be initialized at the start of a run. The configUrl is a "special" variable that will be used as a "default" if no URL is provided for an individual call. You can mix and match for convenience. For example you can change the URL for one single request, experiment with it and then change it back (or have it empty).

image

JS Functions

Coming Soon

Environment Switching

Coming Soon

Saving Files

Coming Soon

Import

Coming Soon

Export

Coming Soon

Clone this wiki locally