TestStep
Added in: v1.10Represents a step in a TestResult.
Methods
testStep.titlePath()
Added in: v1.10Returns a list of step titles from the root step down to this step.
Returns
Array<string>
Properties
testStep.annotations
Added in: v1.51The list of annotations applicable to the current test step.
Type
Array<Object>
testStep.attachments
Added in: v1.50The list of files or buffers attached in the step execution through testInfo.attach().
Type
Array<Object>
testStep.category
Added in: v1.10Step category to differentiate steps with different origin and verbosity. Built-in categories are:
expectfor expect callsfixturefor fixtures setup and teardownhookfor hooks initialization and teardownpw:apifor Playwright API calls.test.stepfor test.step API calls.test.attachfor testInfo.attach API calls.
Type
string
testStep.duration
Added in: v1.10Running time in milliseconds.
Type
float
testStep.error
Added in: v1.10Error thrown during the step execution, if any.
Type
TestError
testStep.location
Added in: v1.10Optional location in the source where the step is defined.
Type
Location
testStep.params
Added in: v1.63Step-dependent parameters, when available. For example, steps produced by the Playwright API calls contain the target locator and the call arguments such as url, while test.step() steps contain the parameters passed by the test author.
// { locator: 'getByRole(\'button\')' }
await page.getByRole('button').click();
// { url: 'https://example.com' }
await page.goto('https://example.com');
// { locator: 'getByLabel(\'Password\')', value: 'secret' }
await page.getByLabel('Password').fill('secret');
// { orderId: 42 }
await test.step('checkout', async () => {
// ...
}, { params: { orderId: 42 } });To keep the reports small, Playwright API calls only report a curated set of arguments per call, and long string values are truncated. Unbounded arguments such as the page content, evaluated expressions or request bodies are never reported.
Type
Object<string, any>
testStep.parent
Added in: v1.10Parent step, if any.
Type
TestStep
testStep.startTime
Added in: v1.10Start time of this particular test step.
Type
Date
testStep.steps
Added in: v1.10List of steps inside this step.
Type
Array<TestStep>
testStep.subtitle
Added in: v1.63User-friendly test step subtitle that complements the title, when available. For Playwright API calls, it is the target locator or the navigation url. For example, a Click step has the clicked locator as a subtitle. test.step() steps carry the subtitle passed by the test author. User interfaces typically render the subtitle next to the title or on a separate line.
// title `Click`, subtitle `getByRole('button')`
await page.getByRole('button').click();
// title `Navigate`, subtitle `example.com/index.html`
await page.goto('https://example.com/index.html');
// title `Add to cart`, subtitle `SKU 42`
await test.step('Add to cart', async () => {
// ...
}, { subtitle: 'SKU 42' });Type
string
testStep.title
Added in: v1.10User-friendly test step title, for example Click or Navigate.
Type
string