Java - Selenium automatically accepting alerts
Does anyone know how to disable this? Or how to get the text from alerts that have been automatically accepted?
This code needs to work,
driver.findElement(By.xpath("//button[text() = \"Edit\"]")).click();//causes page to alert() something Alert alert = driver.switchTo().alert(); alert.accept(); return alert.getText();
but instead gives this error
No alert is present (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 2.14 seconds
I am using FF 20 with Selenium 2.32
There are 4 suggested solutions here and each one has been listed below with a detailed description. The following topics have been covered briefly such as Java, Alert, Selenium, Webdriver. These have been categorized in sections for a clear and precise explanation.