Skip to main content

runStep

Overview

Use the runStep command to obtain a human-readable execution history of the test, which will automatically be displayed in the html-reporter. Steps can be nested.

Usage

await browser.runStep(stepName, stepCb);

Command Parameters

NameTypeDescription
stepNamestringStep name.
stepCb() => Promise<any>A function with commands that need to be combined into a single step.

Usage Examples

it("test", async ({ browser }) => {
await browser.runStep("prepare page", async () => {
await browser.url("some/url");
await browser.setCookies(someCookies);
});

await browser.runStep("make an order", async () => {
await browser.runStep("navigate to the shopping cart", async () => {
await browser.$("not-exist-selector").click();
});
});
});

This test will fail with the error "Cannot call click on element with selector 'not-exist-selector' because element wasn't found" due to the missing selector and the following history will be generated:

- testplane: init browser
- prepare page
- make an order
- navigate to the shopping cart
- $("not-exist-selector")
- click()
- waitForExist

In this example step some step name is collapsed, because it is completed successfully.

You can also return values from step:

const parsedPage = await browser.runStep("parse page", async () => {
// ...
return someData;
});