[UI5][Opa5] What Are You Waiting for in Opa5?
Opa5 is just like life, you could always wait for someting, but before that you’d better know if finally it will be there.
If you have written Opa5 tests for your application, you will believe the waitFor function is one of the most important functions in Opa5. But there are not so many detailed documentations about it. About its functionality I found following statement in here.
So the waitFor function will always success if the control is visible? Maybe not. Recently a colleague came to me and said in her Opa5 tests a visible Column could not be found by waitFor. Then I checked the code. It turns out that the property “minScreenWidth” and “demandPopin” are setted to the column. So maybe during the Opa5 test the column popin, and the waitFor function does not work for a popin column. But why?
Then through the implementation of waitFor. During the whole process many conditions could lead to a failure in looking for the control.
- Firstly it tries to find the control.
- If a viewName and an id are given, it will look for the control with the given id in the given viel.
- If there’s no viewName, it will consider the id as a global id and look for the control.
- If no id is given, it will try to find all the controls with the given controlType.
- If nothing is given, all controls will be return.
- After finding the control / controls, check if the control is available. If one of the following condition are not fulfilled, the whole process failed.
- Use getDomRef function to get the DOM element of the control, which means the control is rendered.
- The control should be visible.
- The control should be not in busy state.
- The control should be enabled.
- All the parents of the control should also be enabled and not busy.
- If all the above condition are fulfilled, the controll will be returned for further actions.
Then on which step failed the popin column? Let’s have a small test. In the following table there are three columns ID, Name and Price. The last column popin. And we could see it cannot find a corresponding DOM element for the popin column. And that is the reason of the failure of waitFor.
And we could see in Column.js the function getDomRef is not rewritten. It only use the control id to find the DOM element, but nothing could be found since the structur of the table is changes.
About the table structur when there are popin columns you could find in my blog [UI5] Things that Demo Kit didn’t tell you. <Column> / [UI5] Dinge, die Demo-Kit Ihnen nicht mitgeteilt hat. <Column>.