When recording in selenium IDE I can click the \"OK\" button in a popup, and expected to be able to click it using
driver.findElement(By.linkText(\"OK\")).cl
in such case I'd prefer to check(verify) the alert presence on the page and then if is present - accept it. It be somthing like:
public boolean isAlertPresent() {
boolean presentFlag = false;
try {
// Check the presence of alert
Alert alert = driver.switchTo().alert();
// Alert present; set the flag
presentFlag = true;
// if present consume the alert
alert.accept();
} catch (NoAlertPresentException ex) {
// Alert not present
ex.printStackTrace();
}
return presentFlag;
}
here you can get details Also do not forget about debug step by step.
Hope this helps you.