class sap.ui.test.OpaBuilder

Control sample: sap.ui.test.OpaBuilder
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Extends:
Module: sap/ui/test/OpaBuilder
Application Component: CA-UI5-TA

Builder pattern for sap.ui.test.Opa5#waitFor options object - a function driven API supporting easy test definition and execution.

Sample usage:

// {
//    id: "myButton",
//    press: new Press()
// }
OpaBuilder.create()
    .hasId("myButton")
    .doPress()
    .build();

Replace this.waitFor call completely:

// return this.waitFor({
//    controlType: "sap.m.StandardListItem",
//    matchers: [
//       {
//           properties: { text: "my test text" }
//       }
//    ],
//    press: new Press(),
//    success: function () {
//        Opa5.assert.ok(true, "Item selected - OK");
//    },
//    errorMessage: "Item selected - FAILURE"
// });
return OpaBuilder.create(this)
    .hasType("sap.m.StandardListItem")
    .hasProperties({ text: "my test text" })
    .doPress()
    .description("Item selected")
    .execute();


Constructor

Constructor for a new OpaBuilder.

new sap.ui.test.OpaBuilder(oOpaInstance?, oOptions?)
Param Type Default Value Description
oOpaInstance? sap.ui.test.Opa5

the Opa5 instance to operate on

oOptions? object

the initial sap.ui.test.Opa5#waitFor options


Methods Overview

Method Description
build

Build the final sap.ui.test.Opa5#waitFor options object and returns it.

check

Add a check function. If another check function already exists, the functions are chained.

checkNumberOfMatches

Adds a check for the expected number of matching controls.

sap.ui.test.OpaBuilder.create

Convenience creation and initialization of a new OpaBuilder.

debugTimeout

Sets the debugTimeout parameter.

sap.ui.test.OpaBuilder.defaultOptions

Set or get the default options to be used as the builder base. If no options are provided, the current default options are returned.

description

Set a output text that will be used as success and error message base message.

do

Add an action to be performed on all matched controls.

doConditional

Add an action that is only performed if target control fulfills the conditions. It is internally using sap.ui.test.OpaBuilder.Actions.conditional.

doEnterText

Performs a sap.ui.test.actions.EnterText on target control(s).

doOnAggregation

Performs given actions on all items of an aggregation fulfilling the matchers.

doOnChildren

Executes a builder with matching controls being descendants of matching target control(s). Children are any controls in the control tree beneath this target control(s).

doPress

Executes a sap.ui.test.actions.Press action on target control(s).

error

Adds an error message or function.

execute

Executes the definition on the given or previously defined Opa5 instance.

fragmentId

Sets the fragmentId parameter.

getOpaInstance

Get the Opa5 instance that will be used for sap.ui.test.OpaBuilder#execute. If no {sap.ui.test.Opa5} instance was set before, this function creates a new one lazily.

has

Defines additional matchers for the target control(s).

hasAggregation

Adds matchers to aggregation items, that at least one aggregation item must match.

hasAggregationLength

Adds a matcher that checks for a certain number of aggregation items.

hasAggregationProperties

Adds a matcher to aggregation items checking for certain properties. At least one item must match the properties.

hasChildren

Adds a matcher that checks whether at least one child fulfilling given matcher(s).

hasConditional

Adds a matcher that checks states for given conditions. It is internally using sap.ui.test.OpaBuilder.Matchers.conditional.

hasI18NText

Adds a matcher for given properties.

hasId

Defines the id of the target control(s).

hasProperties

Adds a matcher for given properties.

hasSome

Adds a group of matchers that requires only one of them to actually match. It is internally using sap.ui.test.OpaBuilder.Matchers.some.

hasType

Defines the control type of the target control(s).

isDialogElement

Defines whether target control is part of a popover or dialog (sets searchOpenDialogs property).

mustBeEnabled

Sets the enabled parameter.

mustBeReady

Sets the autoWait parameter.

mustBeVisible

Sets the visible parameter.

options

Apply custom options. The options might override previously defined options of the OpaBuilder.

pollingInterval

Sets the pollingInterval parameter.

setOpaInstance

Set the Opa5 instance to be used for sap.ui.test.OpaBuilder#execute. Please note that this function does not return the OpaBuilder instance and can therefore not be chained. Use the oOpaInstance argument of sap.ui.test.OpaBuilder.create, sap.ui.test.OpaBuilder#constructor or sap.ui.test.OpaBuilder#execute to provide the Opa5 instance within the builder chain.

success

Adds a success message or function. When providing an OpaBuilder, the action will execute it.

timeout

Sets the timeout parameter.

viewId

Sets the viewId parameter.

viewName

Sets the viewName parameter.

viewNamespace

Sets the viewNamespace parameter.

build

Build the final sap.ui.test.Opa5#waitFor options object and returns it.

check

Add a check function. If another check function already exists, the functions are chained.

Param Type DefaultValue Description
fnCheck function

the check that is executed on matched controls

bReplace boolean

true to replace all previous defined matchers, false to add it (default)

checkNumberOfMatches

Adds a check for the expected number of matching controls.

Param Type DefaultValue Description
iExpectedNumber number

the number of expected matching controls

sap.ui.test.OpaBuilder.create

Convenience creation and initialization of a new OpaBuilder.

Param Type DefaultValue Description
oOpaInstance sap.ui.test.Opa5

the Opa5 instance to operate on

vId string RegExp

the id of the target control(s)

vControlType string

the type of the target control(s)

bDialogElement boolean

if true, only popover and dialogs are searched for

vMatchers sap.ui.test.matchers.Matcher function Array Object

additional matchers to filter target control(s)

vActions sap.ui.test.actions.Action function Array

the actions to be performed on target control(s)

oOptions object

oOptions the sap.ui.test.Opa5#waitFor options to apply

debugTimeout

Sets the debugTimeout parameter.

Param Type DefaultValue Description
iDebugTimeout int

the debug timeout in seconds

sap.ui.test.OpaBuilder.defaultOptions

Set or get the default options to be used as the builder base. If no options are provided, the current default options are returned.

Param Type DefaultValue Description
oOptions object

the new default options to be used

description

Set a output text that will be used as success and error message base message.

Param Type DefaultValue Description
sDescription string

a descriptive text

do

Add an action to be performed on all matched controls.

Param Type DefaultValue Description
vActions sap.ui.test.actions.Action function Array

the action(s) to be performed on matched controls

bReplace boolean

true to replace all previous defined actions, false to add it (default)

doConditional

Add an action that is only performed if target control fulfills the conditions. It is internally using sap.ui.test.OpaBuilder.Actions.conditional.

Param Type DefaultValue Description
vConditions sap.ui.test.matchers.Matcher function Array Object boolean

target control is checked against these given conditions

vSuccessActions sap.ui.test.actions.Action function Array

the actions to be performed when conditions are fulfilled

vElseActions sap.ui.test.actions.Action function Array

the action(s) to be performed when conditions are not fulfilled

doEnterText

Performs a sap.ui.test.actions.EnterText on target control(s).

Param Type DefaultValue Description
sText string

defines the sap.ui.test.actions.EnterText#setText setting

bClearTextFirst boolean

defines the sap.ui.test.actions.EnterText#setClearTextFirst setting

bKeepFocus boolean

defines the sap.ui.test.actions.EnterText#setKeepFocus setting

bPressEnterKey boolean

defines the sap.ui.test.actions.EnterText#setPressEnterKey setting

sIdSuffix string

defines the sap.ui.test.actions.Action#setIdSuffix setting

doOnAggregation

Performs given actions on all items of an aggregation fulfilling the matchers.

Param Type DefaultValue Description
sAggregationName string

the aggregation name

vMatchers sap.ui.test.matchers.Matcher function Array Object

the matchers to filter aggregation items

vActions sap.ui.test.actions.Action function Array

the actions to be performed on matching aggregation items

doOnChildren

Executes a builder with matching controls being descendants of matching target control(s). Children are any controls in the control tree beneath this target control(s).

Param Type DefaultValue Description
vChildBuilderOrMatcher sap.ui.test.matchers.Matcher function Array Object sap.ui.test.OpaBuilder

the child builder or child matcher

vActions sap.ui.test.actions.Action function Array

the actions to be performed on matching child items

bDirect boolean

specifies if the ancestor should be a direct ancestor (parent)

doPress

Executes a sap.ui.test.actions.Press action on target control(s).

Param Type DefaultValue Description
sIdSuffix string

the id suffix of the DOM Element the press action will be executed on

error

Adds an error message or function.

Param Type DefaultValue Description
vErrorMessage string function

the message to be shown (or function executed) on failure

bReplace boolean

true to replace all previous defined error functions, false to add it (default)

execute

Executes the definition on the given or previously defined Opa5 instance.

Param Type DefaultValue Description
oOpaInstance sap.ui.test.Opa5

the Opa5 instance to call sap.ui.test.Opa5#waitFor on

fragmentId

Sets the fragmentId parameter.

Param Type DefaultValue Description
sFragmentId string

the fragment id

getOpaInstance

Get the Opa5 instance that will be used for sap.ui.test.OpaBuilder#execute. If no {sap.ui.test.Opa5} instance was set before, this function creates a new one lazily.

has

Defines additional matchers for the target control(s).

Param Type DefaultValue Description
vMatchers sap.ui.test.matchers.Matcher function Array Object

additional matchers to filter target control(s)

bReplace boolean

true to replace all previous defined matchers, false to add it (default)

hasAggregation

Adds matchers to aggregation items, that at least one aggregation item must match.

Param Type DefaultValue Description
sAggregationName string

the aggregation name

vMatchers sap.ui.test.matchers.Matcher function Array Object

matchers to filter aggregation items

hasAggregationLength

Adds a matcher that checks for a certain number of aggregation items.

Param Type DefaultValue Description
sAggregationName string

the aggregation name

int undefined

iNumber length to check against

hasAggregationProperties

Adds a matcher to aggregation items checking for certain properties. At least one item must match the properties.

Param Type DefaultValue Description
sAggregationName string

the aggregation name

oProperties object

map of properties that aggregation item must match

hasChildren

Adds a matcher that checks whether at least one child fulfilling given matcher(s).

Param Type DefaultValue Description
vBuilderOrMatcher sap.ui.test.matchers.Matcher function Array Object sap.ui.test.OpaBuilder

the matchers to filter child items

bDirect boolean

specifies if the ancestor should be a direct ancestor (parent)

hasConditional

Adds a matcher that checks states for given conditions. It is internally using sap.ui.test.OpaBuilder.Matchers.conditional.

Param Type DefaultValue Description
vConditions sap.ui.test.matchers.Matcher function Array Object boolean

conditions to pre-check

vSuccessMatcher sap.ui.test.matchers.Matcher function Array Object

actual matcher that is executed if conditions are met

vElseMatcher sap.ui.test.matchers.Matcher function Array Object

actual matcher that is executed if conditions are not met

hasI18NText

Adds a matcher for given properties.

Param Type DefaultValue Description
sPropertyName string

the name of the property to check for i18n text

sModelTokenPath string

the path to the I18N text. If model is omitted, i18n is used as model name.

aParameters any[] []

the values to be used instead of the placeholders

hasId

Defines the id of the target control(s).

Param Type DefaultValue Description
vId string RegExp

the id of the target control(s)

hasProperties

Adds a matcher for given properties.

Param Type DefaultValue Description
oProperties object

map of properties that target control(s) must match

hasSome

Adds a group of matchers that requires only one of them to actually match. It is internally using sap.ui.test.OpaBuilder.Matchers.some.

Param Type DefaultValue Description
aMatchers sap.ui.test.matchers.Matcher function Array Object []

aMatchers list of matchers were one must be met

hasType

Defines the control type of the target control(s).

Param Type DefaultValue Description
vControlType string

the type of the target control(s)

isDialogElement

Defines whether target control is part of a popover or dialog (sets searchOpenDialogs property).

Param Type DefaultValue Description
bDialog boolean

can be set to false to disable searchOpenDialogs, set to true if omitted

mustBeEnabled

Sets the enabled parameter.

Param Type DefaultValue Description
bEnabled boolean

can be set to false to prevent enabled check, set to true if omitted

mustBeReady

Sets the autoWait parameter.

Param Type DefaultValue Description
bReady boolean

can be set to false to prevent autoWait, set to true if omitted

mustBeVisible

Sets the visible parameter.

Param Type DefaultValue Description
bVisible boolean

can be set to false to prevent visible check, set to true if omitted

options

Apply custom options. The options might override previously defined options of the OpaBuilder.

Param Type DefaultValue Description
oOptions object

the sap.ui.test.Opa5#waitFor options to apply

pollingInterval

Sets the pollingInterval parameter.

Param Type DefaultValue Description
iPollingInterval int

the polling interval in milliseconds

setOpaInstance

Set the Opa5 instance to be used for sap.ui.test.OpaBuilder#execute. Please note that this function does not return the OpaBuilder instance and can therefore not be chained. Use the oOpaInstance argument of sap.ui.test.OpaBuilder.create, sap.ui.test.OpaBuilder#constructor or sap.ui.test.OpaBuilder#execute to provide the Opa5 instance within the builder chain.

Param Type DefaultValue Description
oOpaInstance sap.ui.test.Opa5

the Opa5 instance to operate on

success

Adds a success message or function. When providing an OpaBuilder, the action will execute it.

Param Type DefaultValue Description
vSuccess string function sap.ui.test.OpaBuilder

the message that will be shown (or function executed) on success

bReplace boolean

true to replace all previous defined success functions, false to add it (default)

timeout

Sets the timeout parameter.

Param Type DefaultValue Description
iTimeout int

the timeout in seconds

viewId

Sets the viewId parameter.

Param Type DefaultValue Description
sViewId string

the viewId

viewName

Sets the viewName parameter.

Param Type DefaultValue Description
sViewName string

the viewName

viewNamespace

Sets the viewNamespace parameter.

Param Type DefaultValue Description
sViewNamespace string

the viewNamespace