2016-09-06 92 views
0

我在按住SAPUI5应用程序的JavaScript视图上的消息框上的不同按钮时遇到问题。其他项目似乎工作就像在文本框中插入文本,按下按钮,选择表中的行等精细SAPUI5 OPA测试 - 消息框 - 错误

我发现每一个消息框都有一个类型/类像sapMDialogSuccesssapMDialogErrorsapMDialogWarning,等我们做OK,Cancel,Abort按钮(在MessageBox上显示)有类似/类别?

我能够得到这对我MessageBox出现使用确切的文本:

ok(true, "This success message is displayed:- " + 
sap.ui.test.Opa5.getJQuery()(".sapMDialogSuccess"). 
find(".sapMText").text()); 

但是当我尝试下面的代码选择(然后按)OK按钮,这是行不通的。这里是我使用的代码:

//OK Button - Find & Press OK button 
Then.waitFor({ 
    pollingInterval: 5, 
    searchOpenDialogs: true, 
    controlType: "sap.m.Button", 

    check: function(aButton) { 
     if (aButton.text() === "OK") { 
      return !!sap.ui.test.Opa5.getJQuery()(".sapMDialogSuccess").length; 
     } 
    }, 
    success: function() { 
     ok(true, "OK button found - SUCCESS"); 
    }, 
    errorMessage: "OK Button not found - ERROR" 
}); 

这里是我得到的错误:

OK Button not found - ERROR 
Callstack: 
    at Object.<anonymous> (http: //<<server>>:50000/XMII/CM/Opa-LineGroupMaintenance.html:152:22) 
    at Object.f (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/test/opaQunit.js:6:331) 
    at Object.run (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:9294) 
    at eval (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:11222) 
    at C (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:5918) 
    at E (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:6299) 
    at eval (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:6431)@ 3618 ms 
Expected: 
true 
Result:  
false 
Diff: 
trufalse 
Source:  
    at Object.eval [as ok] (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:20688) 
Script [email protected] 3623 ms 
Source:  
:0 

回答

0

我发现下面的代码段的工作对我来说:

   Then.waitFor({ 
        pollingInterval: 10, //optional 
        searchOpenDialogs: true, //mandatory 
        //controlType: "sap.m.Button", //optional 
        success: function(oDialogs) { 
         if (oDialogs[oDialogs.length - 1].$().text() === "OK") { 
          oDialogs[oDialogs.length - 1].$().trigger("click"); 
          Opa5.assert.ok(true, "Found OK button inside open dialog!"); 
         } 
        }, 
        errorMessage: "Did not find either the open dialog or buttons inside an open dialog" 
       }); 
1

据工作对我来说这样。我们必须做的成功功能firePress()事件:

Then.onTheTranslationPage.ipressOKButton(); 

ipressOKButton: function() { 
    var oOrderNowButton = null; 
    return this.waitFor({ 
     viewName: sViewName, 
     searchOpenDialogs: true, //mandatory 
     controlType: "sap.m.Button", //optional 
     success: function (aButtons) { 
      return aButtons.filter(function (oButton) { 
       if(oButton.getText() == "OK") { 
        oOrderNowButton = oButton; 
        oButton.firePress(); 
       } 
      }); 

      Opa5.assert.ok(true, "Form Got Submitted Successfully"); 
     }, 
     actions: new Press(), 
     errorMessage: "Did not find the dialog control" 
    }); 
},