2017-09-06 6 views
0

enter image description hereSapui5 OPA5テスト:私はポップアップで開きますフラグメントにどのように入手できますか?

「ホーム」ビューには、フラグメントを含むポップアップを開くボタンがあります。 ポップアップは、DOM要素に追加されるフラグメントです。

私はホームページのOPA5テストを行うと、私はそれが仕事をdoesntの断片と、ポップアップにアクセスしようとしているとき、それはうまく行くが。 (例えば、ボタンをクリックするか画像を取得するなど)。

どのように私はポップアップを参照のうえれる機能を実装することができますか?

sap.ui.require(
["sap/ui/test/opaQunit"], 
function (opaTest) { 
    "use strict"; 

    QUnit.module("Load"); 

    opaTest("View init!", function (Given, When, Then) { 
     // Arrangements 
     Given.iStartMyApp(); 

     //Actions 
     When.onTheHomePage.iLookAtTheScreen(); 
     When.onTheHomePage.iPressOnBotButton(); 
     When.onTheHomePage.iPressInDialog();/// Needs to click in popup 
     When.onTheHomePage.iSearchInDialog();/// Needs to **search** in popup 
     // Assertions 
     Then.onTheHomePage.iShouldSeeTheHelloDialog(); 
    }); 

Home.js

  • Home.view.xml
  • Chat.fragment.xml

ここではOPA5 HomeJourney.jsです

iPressInDialog: function() { 
        // Press action hits the "more" trigger on a table 
        return this.waitFor({ 
         id: "__button13", 
         viewName: "Home", 
         actions: new Press(), 
         errorMessage: "did not find the Button", 
          success : function (oTitle) { 
           Opa5.assert.ok(oTitle.getVisible(), "closeBTN Button Was Clicked"); 
          } 
        }); 
       }, 

Chat.fragment.xml

<core:FragmentDefinition 
xmlns:core="sap.ui.core" 
xmlns:f="sap.ui.layout.form" 
xmlns:l="sap.ui.layout" 
xmlns:wt="com.sap.it.cs.iphome.controller.fragments" 
xmlns:commons="sap.suite.ui.commons" 
xmlns:h="http://www.w3.org/1999/xhtml" 
xmlns="sap.m" 
> 
<Dialog id="Dialog"> 
      <content> 
       <l:HorizontalLayout 
       allowWrapping="false" 
       class="sapUiContentPadding"> 
        <Panel height="auto" width="auto" backgroundDesign="Solid"> 
         <FlexBox> 
          <List items="{msgData>/msgData}" > 
           <CustomListItem > 
             <wt:MessageStrip 
             text="{msgData>Text}" 
             type="{msgData>Type}" 
             showIcon="true" 
             showCloseButton="false" 
             customIcon="{msgData>customIcon}" 
             > 
            </wt:MessageStrip> 
           </CustomListItem> 
          </List> 
          <HBox width="100%"> 
           <SearchField width="auto" class="sapUiSmallMargin" id="searchField" search="onSearch" liveChange="onLiveChange" placeholder="How can I help you?"> 
            <layoutData> 
             <FlexItemData growFactor="1" /> 
            </layoutData> 
           </SearchField> 
           <Button id="speech" icon="sap-icon://microphone" press="onAskClick" class="sapUiSmallMarginTop"> 
           </Button> 
          </HBox> 
         </FlexBox> 
        </Panel> 
       </l:HorizontalLayout> 
      </content> 
</Dialog> 

+0

あなたChat.fragment.xmlはどのようなものが見えますか? i'vはchat.fragment.xmlを追加@Allen – Allen

+0

は、見て、私は「searchField」を取得し、再びそこ – Eli

答えて

1

waitForの使用searchOpenDialogsdocumentationを参照してください。

iSetSearchField: function(sValue) { 
    return this.waitFor({ 
     viewName: "Home", 
     controlType: "sap.m.SearchField", 
     searchOpenDialogs: true, 
     check: function(aSearchField) { 
      if(aSearchField.length > 0) return true; 
      return false; 
     }, 
     success: function(aSearchField) { 
      var oSearchField = aSearchField[0]; 
      oSearchField.setValue(sValue); 
     }, 
     errorMessage: "Cannot set value for search field" 
    }); 
}, 


iClickDialogButton: function() { 
    return this.waitFor({ 
     viewName: "Home", 
     controlType: "sap.m.Button", 
     searchOpenDialogs: true, 
     check: function(aButton) { 
      if(aButton.length > 0) return true; 
      return false; 
     }, 
     success: function(aButton) { 
      var oButton = aButton[0]; 
      oButton.firePress(); 
     }, 
     errorMessage: "Cannot click dialog button" 
    }); 
}, 

あなたの旅コード:

When.onTheHomePage.iSetSearchField("YOUR VALUE"); 
When.onTheHomePage.iClickDialogButton(); 
+0

を値を入力する必要があり、あなたはそれを釘付けしました!!魅力的な作品! :) – Eli

関連する問題