Reputation: 61
i am using selenium and i want to disable all alerts() in webpage.
ExecuteScript("document.body.innerHTML = document.body.innerHTML.replace('alert(', '');");
I tried the above script, but don't have the behaviour that I want.
The code replace but the alert still fired!
Upvotes: 1
Views: 141
Reputation: 38777
I assume that this would work:
ExecuteScript("alert = function() { }");
It will replace the alert
method with an empty function.
Upvotes: 2