0

There is a list on a website and I am trying it simulate a click on that list item. Normally, if I click the list item with the mouse, it gets selected.

The website is created with React. I can see it in React Dev Tools too.

enter image description here

enter image description here

enter image description here

I tried combinations of these on the <li> element:

$($0).click();
$($0).trigger('click');
$($0).mouseover();
$($0).trigger('mouseover');
$($0).mouseenter();
$($0).trigger('mouseenter');

What is the proper way of achieving it?

P.S: The website is 3rd party and I am trying to perform the click via chrome extension - content script (basically with injecting my script in a 3rd party page)

The website is Facebook Ads Manager > Traffic

enter image description here

senty
  • 12,385
  • 28
  • 130
  • 260
  • `document.querySelectorAll('._hpt li')[2].click();` – spencer.sm Jul 21 '17 at 16:09
  • `document.querySelectorAll('._hpt li')[2]` selects but `.click()` doesn't do the trick. I said I tried `.click()`. I put the link in the question, you can try it yourself – senty Jul 21 '17 at 16:11
  • Are you sure you need `click()` and not `focus()`? You also might need to target a `click`-able or `focus`-able element that's deeper than the `
  • ` you've selected. Is there an anchor tag in there?
  • – jered Jul 21 '17 at 18:44
  • I didn't quite get what you mean. In react dev tools, it shows that it's mouseDown & mouseEnter; that's why I started suspecting that it is not `click`. But I want to try your solution, if you can expand it more code-wise. Thanks for your time. Also, I added a link in the question if you want to try it yourself – senty Jul 21 '17 at 18:49