简体   繁体   English

自动单击弹出对话框中的按钮

[英]Autoclick on a button in popped up dialog box

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. 我使用的一种粗略方法是设置一个计时器,以在对话框每100毫秒可见一次时触发单击按钮。

Check the following options: 检查以下选项:

  • For native confirm() or alert() methods, then you cannot click programatically on the buttons to dismiss. 对于本机的confirm()alert()方法,则无法以编程方式单击按钮以将其关闭。 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). 对于基于html的对话框(例如,引导模态),然后使用50ms的反跳启动突变观察器侦听器(反跳将使您减少对添加的元素元素的求值调用)。 When the modal elements are inserted into DOM, trigger a click event on the necessary button from the mutation observer handler. 将模态元素插入DOM后, click从突变观察程序处理程序的必要按钮上触发click事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM