Reputation: 223
I am using following library for Web driver management. I want to disable all the browser alert messages while my test run. Can someone help how to disable alerts using that library? or any workaround ?
import io.github.bonigarcia.wdm.ChromeDriverManager;
Upvotes: 1
Views: 856
Reputation: 17553
JavascriptExecutor worked for me. Just take care that you should execute it before clicking the event which invoke alert. once you set it, it will apply for the whole session
((JavascriptExecutor) driver).executeScript("window.confirm = function(msg) { return true; }");
Note :- do not use it after clicking on event which invoke alert confirmation box. Above code by default set the confirmation box as true means you are accepting/click on ok on all confirmation box on that page if invoked
Hope it will help you :)
Upvotes: 1