cancel
Showing results for 
Search instead for 
Did you mean: 

OPA5 - The control Element is not rendered

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

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"
                            });
                        }

                    });
                },