简体   繁体   中英

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:

   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.

PPS page.find() is how you do querySelector on an E2EPage from Stencil newE2EPage. Documentation is at: https://stenciljs.com/docs/end-to-end-testing#find-an-element-in-the-shadow-dom

What is the page.find() method?

Try to move the focus by clicking another element.

await page.click(selector)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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