Search code examples
jestjspuppeteere2e-testingstenciljs

Find the focused element in end-to-end test for Stencil component


How can I check which element has focus in a Stencil test? I can't use document.activeElement like I would normally do, as it always returns undefined...


Solution

  • I ended up doing:

    const activeElId = await page.evaluate(() => document.activeElement!.id);