search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

1 answers
Q&A Unable to get input element from website
Unable to get input element from website
P粉574695215 2024-04-06 18:59:57 Views 1207

0

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

Your Answer
submit

1 answers
0

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})
2024-04-07 11:23:31

submit

Popular tool

vc9-vc14 (32+64 bit) runtime library collection (link below)

vc9-vc14 (32+64 bit) runtime library collection (link below)

Download the collection of runtime libraries required for phpStudy installation

VC9 32-bit

VC9 32-bit

VC9 32-bit phpstudy integrated installation environment runtime library

PHP programmer toolbox full version

PHP programmer toolbox full version

Programmer Toolbox v1.0 PHP Integrated Environment

VC11 32-bit

VC11 32-bit

VC11 32-bit phpstudy integrated installation environment runtime library

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use