How can I press the OK button in a JS alert programmatically?
What I want to do: every time after the alert is created, the OK button is pressed.
This is for
You can't. Unless you use something that can control the browser (e.g. selenium).
If you do use selenium, have a look at Click in OK button inside an Alert (Selenium IDE)