Unable to click on 'OK' button in the web alert

309 views Asked by At

Am trying to click on 'OK' button in the attached popup using selenium webdriver alert interface.enter image description here

When I inspected the 'OK button using accessibility inspector, it has shown the below properties.

target.processes()["Google Chrome"].frontWindow().images()["Chrome critical alert"].click()
target.processes()["Google Chrome"].frontWindow().buttons()["OK"].click()

So, I have tried webdriver alert to click on 'OK', but it didnt work.

Alert alert = driver.switchTo().alert();

alert.accept();

Have spent enough time on this but couldnt find a solution.Appreciate any help here !

1

There are 1 answers

0
Conrad Albrecht On

That doesn't look like a browser "alert" box to me, so the Alert method won't find it. It also doesn't look like a "popup" (a separate desktop window) in the usual sense. I'm guessing from your description that it's a conventional HTML element on the page. Therefore, you need to find the OK button by usual Selenium element-finding techniques and then click() on the element.