FabricioG
FabricioG

Reputation: 3320

Puppeteer js id element contains

I currently have selected an item in a web page with the xpath:

*[@id="content_gvNewLeads_tccell0_5"]/a

I need to get each one of these elements, there are about 200 on a page. Each id changes slightly.

I've tried this:

  const aLink = await page.$x('//id[contains(content_gvNewLeads_tccel)]/a')

I get an error any idea how I can achieve this?

Upvotes: 0

Views: 913

Answers (1)

mbit
mbit

Reputation: 3013

try this XPath instead:

const aLink = await page.$x('//*[contains(@id,"content_gvNewLeads_tccel")]/a')

Upvotes: 1

Related Questions