← Back to Discord Forum

My Locator suddenly becomes blank

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?"

1 reply

It is difficult to answer without actually looking at the state of the DOM tree. I would suggest debugging with trace viewer.

Related Discord Threads

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 luc@ray.run.