简体   繁体   English

如何处理警报弹出

[英]How to Handle the Alert Pop Up

I am working on the Web Application, In that Application user need to send the values into 我正在使用Web应用程序,在该应用程序中,用户需要将值发送到

the Search Text Box, then user need to click on the Search Button, If the Value are 搜索文本框,然后用户需要单击搜索按钮,如果值是

avilable in the db, then that value will be display on the another Text Box, If that value 在数据库中可用,则该值将显示在另一个文本框中,如果该值

in not in the db, Then Alert Pop up is Displaying on the screen, At that i am using below 在不在数据库中,然后警报弹出窗口显示在屏幕上,当时我正在使用以下

code, But it is not working fine. 代码,但效果不佳。

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

You have an error in the second if, remove the semicolon and it will be better. 如果第二个错误,请删除分号,这样会更好。

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

Anyway if you please tell us WHY is not working I can check if there can be other problems. 无论如何,如果您告诉我们为什么不起作用,我可以检查是否还有其他问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM