Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

320
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!