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

319
Visualizações
Targeting auto-generated elements with node.js puppeteer

I am using puppeteer for node.js v13.3.1, I am building a bot that will apply to jobs on linkedIn. So far I have the following code.

const puppeteer = require('puppeteer');
   const SEARCHPARAM = "react" // change this for search param 
require("dotenv").config();
(async () => {
    const browser = await puppeteer.launch({headless:false});
  const page = await browser.newPage();
  await page.goto('https://www.linkedin.com/login?fromSignIn=true&trk=guest_homepage-basic_nav-header-signin')
  await page.setViewport({ width: 1920, height: 1080});
  await page.type("#username", process.env.NAMEUSERNAME)
  await page.type("#password", process.env.PASSWORD)
  await page.click('button[type="submit"]')
  //works fine
  await Promise.all([
    await page.waitForNavigation(), 
    await page.click('#global-nav > div > nav > ul > li:nth-child(3)'), 
    await page.type('input', SEARCHPARAM ), 
    await page.click('button[type="button"]'),
    await page.click('#ember1052 > span') //Will not hit the button
  ]);


})();

So far the bot is logging in and searching with the SEARCHPARAM just fine, however I am having trouble getting the bot to hit the easy apply button on the job posting. Whenever I target this button I get the id as ember(number) and this number is never the same on different browser windows. I have tried targeting the button by class but node is telling me that it cannot find that selector.
Puppeteer docs for reference docs

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

0

Please see this link for more detailed answer:
How to click element in Puppeteer using xPath

const elements = await page.$x('<xPath>')
await elements[0].click() 

And your XPath selector should be like this:

const element = await page.$x('//button/span[text()="Easy Apply"]')

Code syntax for:
Button element that contain span element which has text inside "Easy Apply"

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