[英]Get HTML elements in nested HTML
该页面具有以下结构:
<html>
<body>
...
<button class="myclass1" type="button">Continue1</button>
...
#document
<html>
<body>
<button class="myclass" type="button">Continue2</button>
如何单击按钮 Continue2?
我正在尝试使用expect-puppeteer。 但是如果你有木偶操作的解决方案,那么我会使用它。
await expect(page).toClick('button', { text: 'Continue2'}); // not work(Nested html)
await expect(page).toClick('button', { text: 'Continue1'}); // work
您需要先检测框架,然后使用它而不是page
。 在木偶戏中:
const frame = page.frames().find(frame => frame.name() === 'iframe-1');
await frame.click('button.myclass');
尝试删除第二个和标签。 我不确定这一点,但也许它有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.