这是我的代码,我需要在其中找到彼此内部的第三个 iframe(Norge bankId) 并尝试单击复选框。这不会触发事件。可能是什么问题?
试图访问复选框的父级,但仍然无效。在普通页面上,复选框单击有效,但 iframe 复选框给了很多困难。
使用赛普拉斯观察到相同的行为。所以尝试了木偶戏,但同样的故事。
async loginNorgeBankId (debuggingPort) {
const width = 2000; const height = 3000;
const browser = await puppeteer.connect({
browserURL: `http://localhost:${debuggingPort}`,
headless: false,
slowmo: 250,
defaultViewport: { width: width, height: height }
});
const pages = await browser.pages();
const page = pages[0];
// await page.setViewport({ width: width, height: height });
await page.setUserAgent('TEST');
// fetch cypress iframe
await page.waitForSelector('iframe[src="https:app-url"]', { visible: true });
const elementHandle = await page.$(
'iframe[src="app-url"]');
const cypressIframe = await elementHandle.contentFrame();
// Fetch core bankId iframe
await cypressIframe.waitForSelector('iframe[name="xxx123"]', { visible: true });
const iFrameContainer = await cypressIframe.$('iframe[name="xxx123"]');
const frame = await iFrameContainer.contentFrame();
// Fetch Norge bankId iframe
await frame.waitForSelector('iframe[title="BankID"]', { visible: true });
const child = await frame.$('iframe[title="BankID"]');
const childFrame = await child.contentFrame();
// Click on first click (work)
await childFrame.waitForSelector('.document-list__document__icon .document-list__document__icon__container img', { visible: true });
await childFrame.click('.document-list__document__icon .document-list__document__icon__container img');
// select checkbox
await childFrame.waitForSelector('.document_footer .checkbox_wrapper input', { visible: true });
console.log('checkbox is visible.....');
const checkBox = await childFrame.$('.document_footer .checkbox_wrapper input');
checkBox.click();
console.log('checkbox is visible.....2');
return true;
}