Conta
Conta

Reputation: 176

Node js Click with puppeteer an element that has no id or name

Hi everyone I'm trying to click with puppeteer three elements that do not have an id, a name and a class; these are the checkboxes and the button that I have to click (www.omegle.com):

enter image description here

i tried to do it through the click with the coordinates but I can't center the elements to click:

  await page.mouse.click(50, 200);

  await page.waitForNavigation();
 })()

So is there a way to click on an element without knowing its id, class or name?

Upvotes: 0

Views: 547

Answers (1)

anthumchris
anthumchris

Reputation: 9072

// open modal by clicking "Text" button
const btnText = await page.waitForSelector('#chattypetextcell img')
await btnText.click()

// click both checkbox labels when modal opens
const selectorCheckboxLabels ='div div p label'
await page.waitForSelector(selectorCheckboxLabels)
const labels = await page.$$(selectorCheckboxLabels)
await labels[0].click()
await labels[1].click()

Upvotes: 1

Related Questions