无法在我的应用程序中验证弹出覆盖

时间:2017-06-01 12:11:42

标签: selenium nullpointerexception

我使用的是使用Cucumber的Selenium webdriver。

我点击了一个打开弹出框的按钮,其中包含很少的网页元素。我需要在弹出框中执行一些验证。但是一旦显示叠加弹出窗口,我就无法使用isDisplayed验证它。

在控制台中,它显示一条错误消息 - java.lang.NullPointerException但我没有在任何变量中传递任何值来验证此弹出框。

我的脚本如下:

    public static void Popupbox() {
    searchbox = (Application_Pagexpath.popupboxheader).isDisplayed();

    try{
        Thread.sleep(100);
        }catch(InterruptedException e){
        e.printStackTrace();    }

    if(searchbox = True) {
    System.out.println("Popup is displayed"); } 
}

我使用的xpath是正确的,这些在firebug中工作正常。你能帮我理解为什么我看到Null指针异常错误以及为什么Selenium无法验证这个覆盖弹出窗口。

叠加弹出窗口的HTML如下:

div id="_paymentHistoryPortlet_WAR_EBillingWebportlet_:paybillHtyForm:dvAdvSearchOverlay" class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow ebillingAdvFltrOverlay ui-draggable ui-overlay-visible" style="width: auto; height: auto; left: 227.7px; top: 0px; visibility: visible; z-index: 1001;" role="dialog" aria-labelledby="_paymentHistoryPortlet_WAR_EBillingWebportlet_:paybillHtyForm:dvAdvSearchOverlay_title" aria-hidden="false" aria-live="polite"
  div class="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top"
    div class="ui-dialog-content ui-widget-content" style="height: auto;"

0 个答案:

没有答案