在使用 stenciljs 中的 newE2EPage 进行端到端测试时,您可以在元素上调用 focus() 以将焦点设置在该元素上:
const page = await newE2EPage({html: `<my-component></my-component>`});
const el = await page.find('my-component');
await el.focus();
如何从元素上移除焦点?
附注我尝试将焦点设置在第二个元素上,但这似乎不起作用。
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)
关于javascript - 如何在 stenciljs E2E 测试中移除焦点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56926816/