Javascript Puppeter:在iframe中找不到选择器登录模式的节点

Javascript Puppeter:在iframe中找不到选择器登录模式的节点,javascript,puppeteer,Javascript,Puppeteer,我想进入登录页面,点击用户名,然后输入用户名 这就是我到目前为止所做的: const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch({ headless: false, slowMo: 200 }); const page = await browser.newPage(); await page.goto('https://fanta

我想进入登录页面,点击用户名,然后输入用户名

这就是我到目前为止所做的:

const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({ headless: false, slowMo: 200 });
    const page = await browser.newPage();
    await page.goto('https://fantasy.espn.com/basketball/team');
    await page.waitFor(2000);
    await page.click('#did-ui-view > div > section > section > form > section > div:nth-child(1) > div > label > span.input-wrapper > input');
    await page.waitFor(2000);
    await page.type('#did-ui-view > div > section > section > form > section > div:nth-child(1) > div > label > span.input-wrapper > input', 'hello', { delay: 100 });  
    await browser.close()
})();
我继续得到这个错误:

 Error: No node found for selector: #did-ui-view > div > section > section > form > section > div:nth-child(1) > div > label > span.input-wrapper > input

我不明白;当我这样做时,控制台中的document.querySelector将返回该路径的输入;为什么找不到该节点?

该元素位于iframe中。因此,首先需要获取框架,然后从该框架中选择元素。您通常会这样做:

让iframeHandle=等待页面。$'disneyid-iframe'; 让frame=等待iframehold.contentFrame; 让inputElement=Wait frame.waitForSelector'did-ui-view>div>section>section>form>section>div:nth-child1>div>label>span.input-wrapper>input' 等待inputElement。键入'hello',{delay:100}; 但是,进程外框架存在一个问题,因此您需要使用-disable features=site per process启动chromium。以下方面应起作用:

const browser=wait puppeter.launch{headless:false,args:['-disable features=site per process']}; const page=await browser.newPage; 等待页面。转到'https://fantasy.espn.com/basketball/team“,{waitUntil:['load','domcontentloaded','networkidle0']}; 等待第页。等待5000; 让iframeHandle=等待页面。$'disneyid-iframe'; 让frame=等待iframehold.contentFrame; 让inputElement=Wait frame.waitForSelector'did-ui-view>div>section>section>form>section>div:nth-child1>div>label>span.input-wrapper>input' 等待inputElement。键入'hello',{delay:100};