on 03-13-2015 6:16 PM
Hi all,
I'm trying to test the behavior of my UI5 application.
The structure is pretty common:
> component.js
> view (folder)
> App.view.xml
> Data.view.xml
> Data.controller.js
> test (folder)
> myOPATest.html
The Data view is embedded in the App view.
I'd like to test the behavior of a control in Data.
Should I look it up like:
When.waitFor({
viewNamespace : "view",
viewName : "Data",
controlType : "sap.m.List",
id: "list",
//other stuff here
});
or somehow differently?
The console only says: found no control with the id list
I don't really know if the view is resolved or if the app is started at all
Any suggestion would be highly welcome
Thanks, regards
Vincenzo
It would really help if you could also post your Data.view.xml and myOPATest.html, otherwise I and possibly others can only make assumptions:
Assumptions:
Some really useful links:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Armin for your insight, I'll try to elaborate a bit more with a simpler test case, with no nested UI control.
I'm working in web IDE, trying to test a UI5 Helium application I've developed there.
The root view is: [project root]/view/App.xml
The test html page with OPA unit tests is located at [project root]/test/opa1.html
The App.view.xml is as follows:
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" xmlns:l="sap.ui.layout" xmlns:t="sap.ui.table" xmlns:ux="sap.ui.ux3"
xmlns:html="http://www.w3.org/1999/xhtml">
<App id="idAppControl">
<pages>
<mvc:XMLView viewName="sap.sls.inbox.view.TaskList" id="idViewMaster" />
</pages>
</App>
</mvc:View>
The test code is trying to grab the App (id="idAppControl") and check that at least one page is there
// Act
Given.iStartMyAppInAFrame("../index.html");
When.waitFor({
viewNamespace: "view.",
viewName : "App",
id: "idAppControl",
matchers : new sap.ui.test.matchers.AggregationFilled({name : "pages"}),
success : function (aButtons) {
ok(true, "View found");
},
errorMessage : "The list did not contain any item"
});
Also, the whole application of course involves a Component.js, where App.view.xml is specified as root view.
Still, also in this case, the framework seems unable to get hold of the App control, even though it's not nested.
when the test page is run, the application under test is showed successfully, so I guess there's some problem with control resolution
Please note that I managed to get the OPA framework to work with WebIDE, for the sample case taken from the UI5 Explored page.
In that case, the root view is created through the createContent method in Component.js, not the rootView property.
Can this make the difference?
Any insight would be greatly appreciated
Thanks, regards
Vincenzo
Hello Vincenzo,
If you are trying to access the view TaskList, why not set that as your viewName? Are you using any routing in your Component.js, as a routing pattern might be directing your app to a different view.
It is worth noting that with routing in your Component.js, you can have the App.view.xml to just initialize the application and the routing will handle any redirects from the routing pattern including the initial state (index.html) as pattern: "" if you already don't have that.
<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" displayBlock="true">
<App id="idAppControl"/>
</mvc:View>
Best Application Practices - Navigation and Routing
Regards,
Armin
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.