DOMException: Failed to execute 'querySelectorAll' on 'Document' when trying to click

Hi @wjc !

If you use page.locator() it will create a Locator object, which has a click() function. See the documentation:

So please try with:

  const wsSwitchBtn = page.locator('button#menu-button--menu');
  console.log('ws---------------' + wsSwitchBtn.textContent());
  await wsSwitchBtn.click();

Or:

page.click('button#menu-button--menu');

I hope it helps

1 Like