如何在 stenciljs E2E 测试中移除焦点

How to remove focus in stenciljs E2E testing

在使用来自 stenciljs 的 newE2EPage 的端到端测试中,您可以在元素上调用 focus() 以将焦点设置在元素上:

   const page = await newE2EPage({html: `<my-component></my-component>`});
   const el = await page.find('my-component');
   await el.focus();

如何从元素上移除焦点?

P.S。我试过将焦点设置在第二个元素上,但这似乎不起作用。

P.P.S。 page.find() 是您在 Stencil newE2EPage 的 E2EPage 上执行 querySelector 的方式。文档位于:https://stenciljs.com/docs/end-to-end-testing#find-an-element-in-the-shadow-dom

什么是page.find()方法?

尝试通过单击另一个元素来移动焦点。

await page.click(selector)