Rayrun
← Back to Discord Forum

Looking for a sanity check before I file a bug...

dirvinautomation_16636posted in #help-playwright
Open in Discord
dirvinautomation_16636

Having issues using locator filter with has. Seems like a bug, but maybe I'm using it wrong.

Here is the minimal example:

import { test } from '@playwright/test';

test("should filter by 'has'", async ({ page }) => {
    await page.goto("https://nczdcr.csb.app/");
    const table = page.locator("table");
    const cell = table.getByRole("cell", { name: "Foo", exact: true });
    await cell.click();
    const row = table.locator("tr").filter({ has: cell });
    await row.click();
    const button = row.getByRole("button", { name: "Bar" });
    await button.click();
});

Please visit the codesandbox I created to see the actual document I created. The issue is that the button.click() is not executed, because playwright can't seem to find the row. Am I using this right?

This is the error I get in the trace:

locator.click: Timeout 10000ms exceeded.
=========================== logs ===========================
waiting for locator('table').locator('tr').filter({ has: locator('table').getByRole('cell', { name: 'Foo', exact: true }) })

Version:

$ ▶ npx playwright --version
Version 1.39.0

[Sidenote]: I added click on all the elements so I can see the elements located in the trace.

This thread is trying to answer question "Is there a bug in Playwright's `has` filter, or is the user implementing it incorrectly?"

2 replies
dirvinautomation_16636

I added an answer to the ticket. I didn't test anything but it's based on my understanding of the has filter.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].