javascript - Puppeteer write in input field - Stack Overflow

I am new to puppeteer and want to write to the username input of this website with puppeteer in headles

I am new to puppeteer and want to write to the username input of this website with puppeteer in headless mode:

The wikipedia example from How to fill an input field using Puppeteer? works fine on wikipedia. On github, something like const selector = "input.form-control.input-block"; worked fine, but not on the login page of spreadshirt. The selector of the input, I want to fill is #username and a document.querySelector("#username") in devtools returns the input no problem. But if I wait for the selector in puppeteer, I run into timeouts.

const puppeteer = require("puppeteer");

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto(";, {
    waitUntil: "networkidle2"
  });

  await page.waitFor("input[name=username]");
  await browser.close();
})();

All my variations of the selector have not been successful so far, like #username, input#username.textinput__input, .textinput__input... When I log the page.content(), the main content div of the page is not logged at all, it is probably loaded later by some javascript. Is it possible to fill the input with puppeteer and how would that look in code?

I am new to puppeteer and want to write to the username input of this website with puppeteer in headless mode: https://partner.spreadshirt.de/login

The wikipedia example from How to fill an input field using Puppeteer? works fine on wikipedia. On github, something like const selector = "input.form-control.input-block"; worked fine, but not on the login page of spreadshirt. The selector of the input, I want to fill is #username and a document.querySelector("#username") in devtools returns the input no problem. But if I wait for the selector in puppeteer, I run into timeouts.

const puppeteer = require("puppeteer");

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto("https://partner.spreadshirt.de/login", {
    waitUntil: "networkidle2"
  });

  await page.waitFor("input[name=username]");
  await browser.close();
})();

All my variations of the selector have not been successful so far, like #username, input#username.textinput__input, .textinput__input... When I log the page.content(), the main content div of the page is not logged at all, it is probably loaded later by some javascript. Is it possible to fill the input with puppeteer and how would that look in code?

Share Improve this question edited Oct 29, 2020 at 11:04 Zoe - Save the data dump 28.3k22 gold badges128 silver badges160 bronze badges asked Feb 21, 2020 at 21:06 BraimeBraime 431 gold badge1 silver badge7 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The element is in an iframe. You need to access the frame first and then interact with the element:

const frame = page.frames().find(frame => frame.url() === "https://accounts.spreadshirt.de/login?context=partner&lang=de");
let input = await frame.waitForSelector('input[type="email"]');
await input.type("[email protected]");

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744170495a4561512.html

相关推荐

  • javascript - Puppeteer write in input field - Stack Overflow

    I am new to puppeteer and want to write to the username input of this website with puppeteer in headles

    8天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信