0

I am unable to generate a mouse click event inside an input box. I am trying to simulate a user doing a mouse click.

I am trying to use the Chrome console to run these and none is working.

I have tried using the below code.

HTML Input Box:

<input type="email" name="email" class="auth0-lock-input" placeholder="yours@example.com"
       autocomplete="off" autocapitalize="off" aria-label="Email" aria-invalid="false"
       value="">

Javascript:

document.getElementsByClassName('auth0-lock-input')[0].click();

Or

document.getElementsByClassName('auth0-lock-input')[0].mouseenter();

Or

let element= document.getElementsByName('email');
for (elt of element) {
   elt.mouseenter();
}

`````````````````React Listener`````````````````````````

trapBubbledEvent: function (topLevelType, handlerBaseName, element) {
    if (!element) {
      return null;
    }
    return EventListener.listen(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType));
  trapCapturedEvent: function (topLevelType, handlerBaseName, element) {
    if (!element) {
      return null;
    }
    return EventListener.capture(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType));
  },
  monitorScrollValue: function (refresh) {
    var callback = scrollValueMonitor.bind(null, refresh);
    EventListener.listen(window, 'scroll', callback);
  },
  dispatchEvent: function (topLevelType, nativeEvent) {
    if (!ReactEventListener._enabled) {
      return;
    }
    var bookKeeping = TopLevelCallbackBookKeeping.getPooled(topLevelType, nativeEvent);
    try {
      ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
    } finally {
      TopLevelCallbackBookKeeping.release(bookKeeping);
}
};
module.exports = ReactEventListener;
`````````````````````````````````
Stacking
  • 51
  • 5

1 Answers1

0

Actually I think that your code is working, but the click() on a input doesnt do any visual effect.

To test it, run:

let input = document.getElementsByClassName('auth0-lock-input')[0]
input.addEventListener('click', () => alert('Clicked') )