0

Using Puppeteer, click("selector_here") method will click on a selector. But the selector keeps changing values!

For example, one time it will be "#search-keyword-901131292" then it will change to something like "#search-keyword-123891237". It's a random number.

Can I use a regex or something to select selectors that contain "#search-keyword-"?

I've tried:

  • page.click("#search-keyword-*")
  • page.click("\b#search-keyword-\b")
  • page.click("/#search-keyword-/")
  • page.click("#search-keyword-".includes())
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
anthonyjdella
  • 481
  • 2
  • 16

1 Answers1

0

This may be inefficient. But another option you have is select all elements with the same tag. Assume it is a you can select all elements that are div. The run sometbing like element.attr("class").indexOf(//class name//) != -1