The page has the structure:
<html>
<body>
...
<button class="myclass1" type="button">Continue1</button>
...
#document
<html>
<body>
<button class="myclass" type="button">Continue2</button>
How can I click a button Continue2?
I'm trying to use expect-puppeteer. But if you have a solution for puppeteer then I will use it.
await expect(page).toClick('button', { text: 'Continue2'}); // not work(Nested html)
await expect(page).toClick('button', { text: 'Continue1'}); // work
You need to detect the frame first, then use it instead of page
. In puppeteer :
const frame = page.frames().find(frame => frame.name() === 'iframe-1');
await frame.click('button.myclass');
Try delete second and tags. I'm not sure about that, but maybe it works.
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.