2013-09-05 42 views
0

我工作的Web應用程序,該應用程序中用戶需要的值送入如何處理警報拉網

搜索文本框中,然後用戶需要點擊搜索按鈕,如果該值是

在db即時拍攝,則該值將在另一個文本框顯示,如果該值

在不在分貝,那麼警報彈出式菜單被顯示在屏幕上,在我使用低於

代碼,但它工作不正常。

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"); 
    } 
} 

回答

0

你在第二個錯誤,如果刪除分號,它會更好。

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"); 
    } 
} 

無論如何,如果你請告訴我們爲什麼不工作我可以檢​​查是否有其他問題。