on 10-31-2017 11:43 AM
Hi,
I am writing OPA5 integration tests for a SAPUI5 application.
When i try to test elements which are in aggregation i run into a problem.
I try to test if a menu has correct amount of elements after clicked.
The view of the menu:
<MenuButton id="plantMenuButton" text="{plantInfo>/plant/customerName} - {plantInfo>/plant/location}" class="bold-font">
<layoutData>
<FlexItemData maxWidth="100%"/>
</layoutData>
<menu>
<Menu id="plantMenu" itemSelected="onMenuAction" items="{plants>/plants}">
<MenuItem text="{plants>customerName} - {plants>location}" key="{plants>id}"/>
</Menu>
</menu>
</MenuButton>
The journey:
opaTest("Should be able to see one plant in the selector", function(Given, When, Then) {
//Actions
When.onTheHomePage.iPressOnPlantSelector();
// Assertions
Then.onTheHomePage.thePlantSelectorShouldShowEveryPlant().and.iTeardownMyAppFrame();
});
The action for the click:
iPressOnPlantSelector: function() {
return this.waitFor({
id: sPlantMenuButtonId,
viewName: sViewName,
actions: new Press(),
errorMessage: "The plant selector does not have a trigger"
});
},
The assertion which fails:
thePlantSelectorShouldShowEveryPlant: function() {
return this.waitFor({
id: sPlantMenuId,
viewName: sViewName,
matchers: new AggregationLengthEquals({
name: "items",
length: 1
}),
success: function() {
Opa5.assert.ok(true, "The plant selector contains one item.");
},
errorMessage: "The plant selector does not contain an item."
});
},
If a run the test, i can see that the click is working and the menu is opened. I tried other ways to get the menu elements but every time i got the result that they are not rendered.
The full error:
[opaTests.qunit.html] The plant selector does not contain an item.
Opa timeout
This is what Opa logged:
The control Element sap.m.Menu#__xmlview1--plantMenu is not rendered - sap.ui.test.matchers.Visible
all results were filtered out by the matchers - skipping the check - sap.ui.test.pipelines.MatcherPipeline
With thanks,
Bálint
I ran into the exact same problem. I found two issues with selecting a MenuButton item - opa5 thinks the item is 'not rendered' even though it's perfectly visible, and new Press() doesn't work for selecting the item. Setting visible: false and using firePress() resolves these issues. Here's code which I find works:
iSelectFromActionsMenu: function (sText) {
return this.waitFor({
viewName: "myView",
id: "actionsMenuButton",
actions: new Press(),
errorMessage: "Menu was looked for but not found.",
success: function (oSelect) {
Opa5.assert.ok(sViewName, "Found menu.");
this.waitFor({
controlType: "sap.m.MenuItem",
visible: false,
matchers: [
new Ancestor(oSelect),
new Properties({ text: "Press me!" })
],
actions: function (oMenuItem) {
oMenuItem.firePress();
},
success: function () {
Opa5.assert.ok(sViewName, "Item was successfully selected.");
},
errorMessage: "Cannot select item from menu"
});
}
});
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.