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
  • 74,770
  • 16
  • 179
  • 206
user5858
  • 1,082
  • 4
  • 39
  • 79

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
  • 18,122
  • 8
  • 37
  • 41