简体   繁体   English

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

[英]How to remove focus in stenciljs E2E testing

In end-to-end testing using newE2EPage from stenciljs you can invoke focus() on an element to set focus on the element: 在使用来自stenciljs的newE2EPage的端到端测试中,您可以在元素上调用focus()以将焦点设置在元素上:

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

How do you remove focus from the element? 如何从元素上移开焦点?

PS I've tried setting focus on a second element but this does not seem to work. PS我尝试将重点放在第二个元素上,但这似乎不起作用。

PPS page.find() is how you do querySelector on an E2EPage from Stencil newE2EPage. PPS page.find()是如何在Stencil newE2EPage的E2EPage上执行querySelector的方法。 Documentation is at: https://stenciljs.com/docs/end-to-end-testing#find-an-element-in-the-shadow-dom 文档位于: https : //stenciljs.com/docs/end-to-end-testing#find-an-element-in-the-shadow-dom

What is the page.find() method? 什么是page.find()方法?

Try to move the focus by clicking another element. 尝试通过单击另一个元素来移动焦点。

await page.click(selector)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM