Unable to get input element from website
P粉574695215
P粉574695215 2024-04-06 18:59:57
0
1
600

So I'm trying to get an input element from Twitter but when I run it it keeps giving me an error like this in node terminal and as a result the browser window created by this code will close itself as it finds Not having the correct input selector. How do I get the correct type of input?

Error: Element of selector not found: input[name="text"]

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    headless: false,
  })
  const page = await browser.newPage();
  page.setViewport({
    width: 1280,
    height: 800,
    isMobile: false
  })
  await page.goto("https://twitter.com/i/flow/login");
  await page.type('input[name="text"]', 'username', {delay: 25})
})();

I tried different selectors, including the class attribute, but I still get the error

P粉574695215
P粉574695215

reply all(1)
P粉704196697

You need to waitForSelector appear on the page before entering. That's why you get the error, it can't find the element.

  await page.waitForSelector('input[name="text"]');
  await page.type('input[name="text"]', 'username', {delay: 25})
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template