在“主页”视图中,我有一个按钮,可以打开包含片段的弹出窗口。 弹出窗口是一个添加到DOM元素的片段。
当我对主页进行OPA5测试时,它很顺利,但是当我尝试使用片段访问弹出窗口时它不起作用。 (例如,单击按钮或获取图像)。
如何实现引用弹出窗口的功能?
这是OPA5 HomeJourney.js :
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
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 :(得分:1)
使用searchOpenDialogs
的{{1}}。见documentation。
waitFor
您的旅程代码:
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"
});
},