Skip to content

Commit

Permalink
feat(wdi5-control): .getControlInfo() for info on capabilities (#214)
Browse files Browse the repository at this point in the history
* feat(metadata): wip for wdi5 clas members

* feat(metadata): wip for wdi5 clas members

* feat(metadata): wip for wdi5 class members

* fix: use getAllPublicMethods ui5 api

* fix: rm use of getPublicMethods due to deprecation

* feat(controlinfo): add control info methods and test

* docs: add generated method doc examples

* chore: rm unnecessary imports

* feat(controlinfo): add control info methods and test

* fix: wdio bridge

* docs: add usage and recipe

Co-authored-by: dominik.feininger <[email protected]>
  • Loading branch information
dominikfeininger and dominikfeininger committed Apr 20, 2022
1 parent 18c65dd commit 073d917
Show file tree
Hide file tree
Showing 9 changed files with 406 additions and 8 deletions.
6 changes: 5 additions & 1 deletion client-side-js/getControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ async function clientSide_getControl(controlSelector) {
// ui5 control
const ui5Control = window.wdi5.getUI5CtlForWebObj(domElement)
const id = ui5Control.getId()
const className = ui5Control.getMetadata()._sClassName
window.wdi5.Log.info(`[browser wdi5] control with id: ${id} located!`)
const aProtoFunctions = window.wdi5.retrieveControlMethods(ui5Control)
// @type [String, String?, String, "Array of Strings"]
done(["success", { domElement: domElement, id: id, aProtoFunctions: aProtoFunctions }])
done([
"success",
{ domElement: domElement, id: id, aProtoFunctions: aProtoFunctions, className: className }
])
})
.catch(errorHandling)
},
Expand Down
19 changes: 19 additions & 0 deletions docs/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,22 @@ it("get combobox single item aggregation as ui5 control", async () => {
expect(await items.getTitle()).toEqual("Bahrain")
})
```

## use control info for analysis

The control info object contains the following information:

- id?: string // full UI5 control id as it is in DOM
- methods?: string[] // list of UI5 methods attached to wdi5 control
- className?: string // UI5 class name
- $?: Array<string> // list of UwdioI5 methods attached to wdi5 control
- key?: string // wdio_ui_key

```js
it("check the controlInfo for className", async () => {
const button = await browser.asControl(oButtonSelector)
const controlInfo = button.getControlInfo() // <--
// can be accessed on the object
expect(controlInfo.className).toEqual("sap.m.Button")
})
```
243 changes: 243 additions & 0 deletions docs/ui5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
# Functions

## Example sap.m.Button

```Json
{"methods":[
"getText",
"setText",
"getType",
"setType",
"getWidth",
"setWidth",
"getEnabled",
"setEnabled",
"getIcon",
"setIcon",
"getIconFirst",
"setIconFirst",
"getActiveIcon",
"setActiveIcon",
"getIconDensityAware",
"setIconDensityAware",
"getTextDirection",
"setTextDirection",
"getAriaHasPopup",
"setAriaHasPopup",
"getAriaDescribedBy",
"addAriaDescribedBy",
"removeAriaDescribedBy",
"removeAllAriaDescribedBy",
"getAriaLabelledBy",
"addAriaLabelledBy",
"removeAriaLabelledBy",
"removeAllAriaLabelledBy",
"attachTap",
"detachTap",
"fireTap",
"attachPress",
"detachPress",
"firePress",
"getMetadata",
"useEnabledPropagator",
"setContextMenu",
"getContextMenu",
"initBadgeEnablement",
"updateBadgeValue",
"addCustomData",
"insertCustomData",
"getBadgeCustomData",
"getBadgeAnimationClass",
"removeBadgeCustomData",
"setBadgeAccentColor",
"setBadgePosition",
"updateBadgeVisibility",
"updateBadgeAnimation",
"badgeValueFormatter",
"setBadgeMinValue",
"setBadgeMaxValue",
"onBadgeUpdate",
"exit",
"ontouchstart",
"ontouchend",
"ontouchcancel",
"ontap",
"onkeydown",
"onkeyup",
"onfocusin",
"onfocusout",
"getPopupAnchorDomRef",
"getAccessibilityInfo",
"getBlocked",
"setBlocked",
"getBusy",
"setBusy",
"getBusyIndicatorDelay",
"setBusyIndicatorDelay",
"getBusyIndicatorSize",
"setBusyIndicatorSize",
"getVisible",
"setVisible",
"getFieldGroupIds",
"setFieldGroupIds",
"attachValidateFieldGroup",
"detachValidateFieldGroup",
"fireValidateFieldGroup",
"clone",
"addStyleClass",
"removeStyleClass",
"toggleStyleClass",
"hasStyleClass",
"isActive",
"invalidate",
"rerender",
"getDomRef",
"allowTextSelection",
"attachBrowserEvent",
"detachBrowserEvent",
"placeAt",
"onselectstart",
"getIdForLabel",
"destroy",
"isBusy",
"getControlsByFieldGroupId",
"checkFieldGroupIds",
"triggerValidateFieldGroup",
"getTooltip",
"setTooltip",
"destroyTooltip",
"getCustomData",
"removeCustomData",
"removeAllCustomData",
"indexOfCustomData",
"destroyCustomData",
"getLayoutData",
"setLayoutData",
"destroyLayoutData",
"getDependents",
"addDependent",
"insertDependent",
"removeDependent",
"removeAllDependents",
"indexOfDependent",
"destroyDependents",
"getDragDropConfig",
"addDragDropConfig",
"insertDragDropConfig",
"removeDragDropConfig",
"removeAllDragDropConfig",
"indexOfDragDropConfig",
"destroyDragDropConfig",
"register",
"deregister",
"getInterface",
"toString",
"prop",
"getUIArea",
"addDelegate",
"removeDelegate",
"addEventDelegate",
"removeEventDelegate",
"getFocusDomRef",
"focus",
"getFocusInfo",
"applyFocusInfo",
"getTooltip_AsString",
"getTooltip_Text",
"data",
"findElements",
"bindElement",
"unbindElement",
"getElementBinding",
"getDomRefForSetting",
"attachValidationSuccess",
"detachValidationSuccess",
"fireValidationSuccess",
"attachValidationError",
"detachValidationError",
"fireValidationError",
"attachParseError",
"detachParseError",
"fireParseError",
"attachFormatError",
"detachFormatError",
"fireFormatError",
"attachModelContextChange",
"detachModelContextChange",
"fireModelContextChange",
"applySettings",
"getId",
"setProperty",
"getProperty",
"validateProperty",
"isPropertyInitial",
"resetProperty",
"getOriginInfo",
"setAssociation",
"getAssociation",
"addAssociation",
"removeAssociation",
"removeAllAssociation",
"validateAggregation",
"setAggregation",
"indexOfAggregation",
"insertAggregation",
"addAggregation",
"removeAggregation",
"removeAllAggregation",
"destroyAggregation",
"isInvalidateSuppressed",
"setParent",
"getParent",
"isBinding",
"extractBindingInfo",
"getBindingInfo",
"bindObject",
"unbindObject",
"bindContext",
"unbindContext",
"bindProperty",
"unbindProperty",
"updateProperty",
"updateModelProperty",
"bindAggregation",
"unbindAggregation",
"updateAggregation",
"refreshAggregation",
"propagateMessages",
"isTreeBinding",
"updateBindings",
"isBound",
"getObjectBinding",
"getEventingParent",
"getBinding",
"getBindingPath",
"setBindingContext",
"setElementBindingContext",
"updateBindingContext",
"getBindingContext",
"setModel",
"addPropagationListener",
"removePropagationListener",
"getPropagationListeners",
"propagateProperties",
"getModel",
"getOwnModels",
"hasModel",
"findAggregatedObjects",
"onOwnerDeactivation",
"onOwnerActivation",
"isDestroyStarted",
"isDestroyed",
"attachEvent",
"attachEventOnce",
"detachEvent",
"hasListeners",
"isA",
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
"valueOf",
"toLocaleString"
]}
```
22 changes: 22 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,25 @@ In the test, you can navigate the UI5 webapp via `goTo(options)` in one of two w
// or:
await wdi5.goTo({ sHash: "#/Other" })
```

## Control Info

Control info is an object which can be retrieved from any wdi5 control by calling `getControlInfo()`. The control information object is loosely based on the UI5 metadata and also contains `className` and `id`.

The list of attached wdio methods can be found in `$` and the UI5 control methods in the property `methods`.

These properties can help to indentify the received control or test the control correctness.

```js
const button = browser.asControl(oButtonSelector)
const controlInfo = button.getControlInfo() // <--
/*
* id?: string // full UI5 control id as it is in DOM
* methods?: string[] // list of UI5 methods attached to wdi5 control
* className?: string // UI5 class name
* $?: Array<string> // list of UwdioI5 methods attached to wdi5 control
* key?: string // wdio_ui_key
*/
})
```
54 changes: 54 additions & 0 deletions docs/wdio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Element

## Function List

```Json
"$",
"$$",
"addValue",
"clearValue",
"click",
"custom$$",
"custom$",
"doubleClick",
"dragAndDrop",
"getAttribute",
"getCSSProperty",
"getComputedLabel",
"getComputedRole",
"getHTML",
"getLocation",
"getProperty",
"getSize",
"getTagName",
"getText",
"getValue",
"isClickable",
"isDisplayed",
"isDisplayedInViewport",
"isEnabled",
"isEqual",
"isExisting",
"isFocused",
"isSelected",
"moveTo",
"nextElement",
"parentElement",
"previousElement",
"react$$",
"react$",
"saveScreenshot",
"scrollIntoView",
"selectByAttribute",
"selectByIndex",
"selectByVisibleText",
"setValue",
"shadow$$",
"shadow$",
"touchAction",
"waitForClickable",
"waitForDisplayed",
"waitForEnabled",
"waitForExist",
"waitUntil"
```
14 changes: 14 additions & 0 deletions examples/ui5-js-app/webapp/test/e2e/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ describe("ui5 basic", () => {
expect(await browser.asControl(searchFieldSelector).getValue()).toEqual("search Value")
}) */

it("check the metadata", async () => {
const button = await browser.asControl({
selector: {
id: "openDialogButton",
viewName: "test.Sample.view.Main"
}
})
const metadata = button.getControlInfo()

expect(metadata.id).toEqual("container-Sample---Main--openDialogButton")
expect(metadata.className).toEqual("sap.m.Button")
expect(metadata.key).toEqual("openDialogButtontestSample.view.Main")
})

it("check getBinding returns a proper object", async () => {
const title = await browser.asControl(titleSelector)
const bindingInfo = await title.getBinding("text")
Expand Down
2 changes: 0 additions & 2 deletions examples/ui5-js-app/webapp/test/e2e/wdioBridge.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { it } = require("mocha")
const { Logger } = require("../../../../../dist/lib/Logger")
const Main = require("./pageObjects/Main")

const titleSelector = {
Expand Down
Loading

0 comments on commit 073d917

Please sign in to comment.