0

How can I detect the mouse position ACCORDING TO ITS RELATIVE POSITION

I mean if I'm in the middle of the page and I log the mouse positionX (I want to log 0) And if i moved the mouse to the left / right 1px (I want to log 1) How can I do that? I searched alot and all I found clientX; pageX; offsetLeft; etc.. Thanks all

Amr
  • 1
  • 2
  • 1
    Does this answer your question? [Collect elements by class name and then click each one - Puppeteer](https://stackoverflow.com/questions/48673906/collect-elements-by-class-name-and-then-click-each-one-puppeteer) – GalAbra Aug 28 '21 at 18:34
  • 1
    Welcome to SO! Which one do you want to click? You can select by type index, `.ars:nth-child(1)` or by `input[type="text"]`. You could also use the parent selector, or any other number of other approaches that might be best for whatever site you're scraping and whatever you might be trying to accomplish (context is always welcome). – ggorlen Aug 28 '21 at 18:43

1 Answers1

0
  1. Use more specific selector:
await page.click('input.ars[type="password"]');
  1. Or use indexed element handles:
const elements = await page.$$('input.ars');
await elements[1].click();
vsemozhebuty
  • 12,992
  • 1
  • 26
  • 26