[英]How to Handle the Alert Pop Up
我正在使用Web應用程序,在該應用程序中,用戶需要將值發送到
搜索文本框,然后用戶需要單擊搜索按鈕,如果值是
在數據庫中可用,則該值將顯示在另一個文本框中,如果該值
在不在數據庫中,然后警報彈出窗口顯示在屏幕上,當時我正在使用以下
代碼,但效果不佳。
if(driver.findElement(By.id(APL.MT_ET_Search_Btn_ID)).isEnabled())
{
driver.findElement(By.id(APL.MT_ET_Search_Btn_ID)).click();
System.out.println("Clicked on the Search Button for the Text box");
Thread.sleep(2000);
//Handling the Code
String page = driver.getTitle();
System.out.println(page);
if(page.equals("No Recipients found"));
{
System.out.println("No Recipients found");
driver.switchTo().alert().accept();
System.out.println("Handling the Pop Up");
}
}
如果第二個錯誤,請刪除分號,這樣會更好。
if(driver.findElement(By.id(APL.MT_ET_Search_Btn_ID)).isEnabled())
{
driver.findElement(By.id(APL.MT_ET_Search_Btn_ID)).click();
System.out.println("Clicked on the Search Button for the Text box");
Thread.sleep(2000);
//Handling the Code
String page = driver.getTitle();
System.out.println(page);
if(page.equals("No Recipients found")) //#############HERE
{
System.out.println("No Recipients found");
driver.switchTo().alert().accept();
System.out.println("Handling the Pop Up");
}
}
無論如何,如果您告訴我們為什么不起作用,我可以檢查是否還有其他問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.