question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

i use page.type(selector, text[, options]) i want to input one element ,but actual input other element

See original GitHub issue

code:

const puppeteer = require('puppeteer');

puppeteer.launch().then(async function(browser) {
  const page = await browser.newPage();
  await page.goto("https://github.com/", { waitUntil : ['load', 'domcontentloaded']});
  await page.type(".js-chromeless-input-container .js-site-search-focus", "841185308");
  await page.screenshot({path: '2.png', fullPage: true});
})

What is the expected result? image

What happens instead? image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
aslushnikovcommented, May 17, 2018

The following works just fine for me:

const puppeteer = require('puppeteer');

puppeteer.launch().then(async function(browser) {
  const page = await browser.newPage();
  await page.setViewport({
    width: 1600,
    height: 600
  });
  await page.goto("https://github.com/", { waitUntil : ['load', 'domcontentloaded']});
  const selector = 'input.form-control.header-search-input.js-site-search-focus';
  await page.waitForSelector(selector);
  await page.type(selector, "841185308");
})
1reaction
mboesercommented, May 10, 2018

@yanguoyu try setting a larger viewport, it worked for me when I did

await page.setViewport({width: 1200, height: 1500});

Read more comments on GitHub >

github_iconTop Results From Across the Web

<input>: The Input (Form Input) element - HTML
The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide...
Read more >
page.type() doesn't work but element.setAttribute() does?
Apparently an element has to be visible before page.type() will work, whereas setting the element's value via attribute doesn't care as long ...
Read more >
5 Selectors
The :focus pseudo-class applies while an element has the focus (accepts keyboard events or other forms of text input). An element may match...
Read more >
Element selectors | Playwright
Selectors are strings that point to the elements in the page. They are used to perform actions on those elements by means of...
Read more >
Scraping & asserting on page elements
How to scrape web page elements like texts, buttons and forms with Google ... We use $page.eval() and pass it two arguments: 1)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found