Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

355
Visualizações
How to select a search bar without a `name`?

I would like to perform a search in the below search bar using Puppeteer. However I can't see anything I can use to identify the search bar by.

If I do:

await page.type('[id="i0e792821-542f-11ec-9366-f3e8261f9ecb"]', 'test="1 2" and test2="3 4"');
await page.type('["data-test-subj"="queryInput"]', 'test="1 2" and test2="3 4"');
await page.type('[class=".euiTextArea.euiTextArea--resizeVertical.euiTextArea--fullWidth.kbnQueryBar__textarea.kbnQueryBar__textarea--hasPrepend.kbnQueryBar__textarea--hasAppend"]', 'test="1 2" and test2="3 4"');
await page.type("*[role='search']", 'test="1 2" and test2="3 4"');

then the first 3 give:

Error: No node found for selector:

and the last one doesn't give any errors.

If I do:

await page.waitForSelector('i0e792821-542f-11ec-9366-f3e8261f9ecb');
await page.focus('i0e792821-542f-11ec-9366-f3e8261f9ecb');
await page.focus('i0e792821-542f-11ec-9366-f3e8261f9ecb', '1234', {delay: 1500});

I get:

TimeoutError: waiting for selector `i0e792821-542f-11ec-9366-f3e8261f9ecb` failed: timeout 30000ms exceeded

What can I use to fill in text in the search bar?

enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

If you want to stick with your second methodology, you need to use the correct CSS selector by prepending a # to indicate the value i0e792821-542f-11ec-9366-f3e8261f9ecb is an id value, and to switch the last line to call page.type() instead of page.focus() (which doesn't take more than one argument nor implements any sort of typing functionality):

await page.waitForSelector('#i0e792821-542f-11ec-9366-f3e8261f9ecb');
await page.focus('#i0e792821-542f-11ec-9366-f3e8261f9ecb');
await page.type('#i0e792821-542f-11ec-9366-f3e8261f9ecb', '1234', {delay: 1500});

However with selectors that aren't super human-readable, you should generally assume that they are dynamically generated somewhere at build or run-time and will change over time - every time it changes your script will break and you'll have to re-work your code to update the selector. Instead, use a selector that's a bit more human-readable and thus more likely to remain constant:

await page.waitForSelector('[data-test-subj="queryInput"]');
await page.focus('[data-test-subj="queryInput"]');
await page.type('[data-test-subj="queryInput"]', '1234', {delay: 1500});
about 4 years ago · Juan Pablo Isaza Relatório

0

I don't really know Puppeteer (or the syntax), but I would imagine something like; div[role="search"].textarea or div[role="search"] > textarea

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda