繁体   English   中英

如何处理警报弹出

[英]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.

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