Good Day,
I have s small function where i have a locator and logs the inner texts. I click on something inside that. Then i try to log the contents of that locator again and now it is empty.
export const isQuickActionButtonPresent = async (quickActionBlock: Locator, quickAction: string): Promise<boolean> => { const buttonSelector =
button:has-text('${quickAction}'); const quickActionButton = quickActionBlock.locator(buttonSelector); console.log(await quickActionBlock.allInnerTexts()); if ((await quickActionButton.count()) === 0) { await quickActionBlock.locator(quickActionsSelector.moreButton).click(); await waitAHotSecond(); } console.log(await quickActionBlock.allInnerTexts()); console.log(await quickActionButton.count()); return (await quickActionButton.count()) > 0; };
on the first console log, i get some text out but on the second console.log i get empty.
This thread is trying to answer question "Why does the locator become empty after clicking on something inside it?"
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].