如何处理注销应用程序时出现的对话框

How to handle a dialogue appearing while getting logout of the application

在我的 Web 应用程序中,我正在使用 OK 按钮和 Cancel 按钮进行对话。

有人可以建议如何以编程方式单击此对话框中的 ok 按钮吗?

您可以尝试切换到提醒并接受或取消。

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

alert.dismiss();

如果提醒需要时间加载,您需要等待。例如如下:

WebDriverWait wait = new WebDriverWait(driver,10);
wait.until(ExpectedConditions.alertIsPresent()).accept();