Hi,
I have an element (rule) with with an undefined name and I would like to rename, that.
e.g.
const newRule = page.locator('div.card', { hasText: /Unnamed Rule/ });
// Setup name.
await newRule.getByRole('heading').first().dblclick();
await newRule.getByRole('textbox').fill(ruleName);
But once I dblclick the heading, the heading is removed and replaced with a form, so the selector is not valid anymore. But the next selector then evaluates the full selector from the start. Can I just "pin" the locator or resolve it, so that it points to the rule card?
This thread is trying to answer question "Can I 'pin' or 'resolve' a Playwright locator to a specific element after the DOM changes?"
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].