Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: use 'Clear' step name for locator.clear() (#36208)

Max Schmittb25cb7f3d186
diff --git a/packages/playwright-core/src/client/locator.ts b/packages/playwright-core/src/client/locator.ts
index ceb607ab5c..9e759c2f34 100644
--- a/packages/playwright-core/src/client/locator.ts
+++ b/packages/playwright-core/src/client/locator.ts
@@ -142,7 +142,7 @@ export class Locator implements api.Locator {
}
async clear(options: channels.ElementHandleFillOptions = {}): Promise<void> {
- return await this.fill('', options);
+ await this._frame._wrapApiCall(() => this.fill('', options), { title: 'Clear' });
}
async _highlight() {
diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.ts
index 3998dce492..af3aa21219 100644
--- a/tests/playwright-test/test-step.spec.ts
+++ b/tests/playwright-test/test-step.spec.ts
@@ -1180,6 +1180,8 @@ test('should report api steps', async ({ runInlineTest, server }) => {
});
test('pass3', async () => {
await myPage.getByRole('textbox').fill('foo');
+ await myPage.getByRole('textbox').fill('');
+ await myPage.getByRole('textbox').clear();
});
test.afterAll(async () => {
@@ -1202,9 +1204,11 @@ pw:api |Click locator('button') @ a.test.ts:25
hook |After Hooks
hook |Before Hooks
pw:api |Fill "foo" getByRole('textbox') @ a.test.ts:28
+pw:api |Fill "" getByRole('textbox') @ a.test.ts:29
+pw:api |Clear getByRole('textbox') @ a.test.ts:30
hook |After Hooks
-hook | afterAll hook @ a.test.ts:31
-pw:api | Close context @ a.test.ts:32
+hook | afterAll hook @ a.test.ts:33
+pw:api | Close context @ a.test.ts:34
hook |Before Hooks
fixture | browser
pw:api | Launch browser