Create OPA Tests for SAP Fiori Elements V4-based List Report Application(WIP)
This is to summarize key points during development of OPA tests for SAP FE V4-based LROR(list report&object page) applications; content will be updated continuously.
SAPUI5 provides FE V4 OPA libraries for better supporting creation of OPA tests; and it is under namespace sap.fe.test. Two keywords: action and assertion.
Start FE V4 Based Application
The first step of running OPA tests is the launch of the application. Same as running a SAPUI5 application, it can be started either by an standalone entry HTML file or by a Fiori Launchpad. One of the advantages of the latter option is Shell functionalities, such as navigation back(iNavigateBack), can be used during tests running.
Standalone HTML file. Need to create an entry HTML such as index.html if it doesn't exist. Then specify the relatvive path and name of the file in the starting file.
Launchpad sandbox. Same as index.html, need to create one if not exist yet. Then specify the same in the starting file. Same code as below. /test/flpSandbox.html can be replaced with a standalone index.html.
Test a Multi-Table List Report
Provide data as filter, then navigate through all tables on the list report to see if data is loaded correctly. API for getting the LR table is sap.fe.test.ListReport.onTable; pass the key as its parameter. The key is defined in the manifest.json.
Test Actions on the List Report
Select a row and execute a bound action such as 'Copy'. After executing 'Copy', check if navigate to the object page and the newly copied is presented in edit mode.
- Get the table by ListReeport.onTable
- Select one row by api.TableActions.iSelectRows
- Execute bound action by api.TableActions.iExecuteAction
Test Extented Object Page Section
There is an manifest-based extended section on the object page. And on the section, there is a tree table which works in both display and edit modes.
- Go to extended secion by ObjectPage.iGoToSection
- Get the tree table. Since the tree table is a SmartTable, need to get it by our own code instead of OPA lib. Such as:
Test Updating Values on the Object Page
Try to update values of specifed fields. Either on a table or on a form.
- Table
- Go to the secion by iGoToSection
- Get the table by ObjectPage.onTable
- Change values by TableActions.iChangeRow
- Form
- Go to the secion by iGoToSection
- Get the form by ObjectPage.onForm
- Change values by FormActions.iChangeField
Test Activating Draft Data and Save, or Discarding
Activate draft data to save it formally or discard it. Then search it by giving unique filter on the list report. Check the newly activated data can be found.
- Return back to the object page of the root entity if necessary
- Get the foot toolbar by ObjectPage.onFooter
- Activate it by FooterActionsOP.iExecuteSave. Or discard it by FooterActionsOP.iExecuteCancel.iConfirmCancel.
Karma configuration
OPA tests can be started without Karma. But in order to get coverage report after OPA running, then we need to use it.
Comments
Post a Comment