2016-09-06 94 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" 
    }); 
},