我想输入并从一个网站内的iframe中获取一些信息。但我的问题是,我无法读取iFrame中的任何元素。它记录了它加载了内容框架,但之后不能以任何元素为目标。
waitForSelector为"null“
另外,当我试图跳过类型时,我得到了错误信息,无法读取属性‘waitForSelector’of null。
await page.waitForSelector("body > div.body.clearfix.container_20 > div.main.grid_12 > iframe");
// need to target IFRAME
const frameHandle = await page.$('iframe[class="orderFrame"]');
const frame = await frameHandle.contentFrame();
console.log('iFrame load succesfull')
// paste ORG
const OrgInput1 = "#Netui_Form_0 > table > tbody > tr:nth-child(4) > td > table > tbody > tr > td > table > tbody > tr:nth-child(3) > td:nth-child(2) > input[type=text]";
await frame.waitForSelector(OrgInput1);
await frame.type(OrgInput1, orgNumber, {delay:100});
// click Next
await frame.waitFor(2000);
发布于 2020-04-10 00:35:35
看起来你不能访问框架内容(框架为空)。可能是OOPIF。尝试使用--disable-features=site-per-process
启动Try /puppeteer。
https://stackoverflow.com/questions/61122214
复制相似问题