Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在stenciljs E2E测试中消除焦点_Javascript_Puppeteer_E2e Testing_Stenciljs - Fatal编程技术网

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

Javascript 如何在stenciljs E2E测试中消除焦点,javascript,puppeteer,e2e-testing,stenciljs,Javascript,Puppeteer,E2e Testing,Stenciljs,在使用来自stenciljs的newE2EPage进行端到端测试时,可以对元素调用focus(),以设置该元素的焦点: const page = await newE2EPage({html: `<my-component></my-component>`}); const el = await page.find('my-component'); await el.focus(); const page=wait newE2EPage({html:`

在使用来自stenciljs的newE2EPage进行端到端测试时,可以对元素调用focus(),以设置该元素的焦点:

   const page = await newE2EPage({html: `<my-component></my-component>`});
   const el = await page.find('my-component');
   await el.focus();
const page=wait newE2EPage({html:``});
const el=wait page.find('my-component');
等待el.focus();
如何从元素中移除焦点

另外,我试着把注意力集中在第二个元素上,但这似乎不起作用


p.p.S.page.find()是如何从Stencil newE2EPage查询E2EPage上的选择器。文档位于:

什么是
页面。find()
方法

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

await page.click(selector)

newE2EPage提供了page.find()方法作为querySelector的替代项。参考这里:谢谢你的回答。我测试了所有三种方法,并在三个等待页面中选择一个。单击(选择器)可以工作。其他两种方法page.focus和page.eval无效。page.focus根本不执行此任务,page.$eval将不会编译。如果您可以将答案更改为仅页面。单击(选择器),我会将其标记为正确。值得一提的是,其他两种方法都不起作用。当然,只是改变了答案。