0

How to auto-click on Yes or No button on a dialog box which pops up on a website?

One crude way I'm using is to set a timer to trigger click on button if the dialog box is visible once every 100ms.

Xan
  • 71,217
  • 14
  • 165
  • 189
user5858
  • 1,004
  • 2
  • 35
  • 72

1 Answers1

1

Check the following options:

  • For native confirm() or alert() methods, then you cannot click programatically on the buttons to dismiss. They can be closed only on user interaction.
  • For html based dialog box (bootstrap modal for example), then initiate a mutation observer listener with a debounce of 50ms (debouncing will allow you to reduce the evaluation calls on bunch of elements added). When the modal elements are inserted into DOM, trigger a click event on the necessary button from the mutation observer handler.
Dmitri Pavlutin
  • 16,530
  • 7
  • 35
  • 38