Click to confirm a Modal Dialog with Selenium WebDriver Click to confirm a Modal Dialog with Selenium WebDriver selenium selenium

Click to confirm a Modal Dialog with Selenium WebDriver


It looks like not frame. If it is frame then you can insect those buttons. So are you able to inspect those buttons? if not then it is alert which is cased by javascript. Use switch to alert here

   Alert alert = driver.switchTo().alert();    alert.accept(); // for OK

Thank You,Murali


Hi thats not frame that's alert and there is Alert method defined in selenium for performing action :Below are the various operations that you can perform on alerts (for more operations look official documentation)

        // working with alerts.        Alert alert = driver.switchTo().alert();        // for clicking on ok button        alert.accept();        // for clicking on cancel button        alert.dismiss();        // for getting alert text message        alert.getText();        // for sending some text inside the alert        alert.sendKeys("alert string");