ui5-community / wdi5

official UI5 end-to-end test framework for UI5 web-apps. wdi5 = Webdriver.IO + UI5 Test API
https://ui5-community.github.io/wdi5/
Apache License 2.0
102 stars 43 forks source link

getBinding() results are not returned into wdi5 test #224

Closed edvardas-kireilis closed 2 years ago

edvardas-kireilis commented 2 years ago

Describe the bug We were calling getBinding() function of a control and results were the control itself and not the binding object which is returned as ui5 control getBinding() result. It seems that in client-side-js/executeControlMethod.js file code is checking if method result is a primitive, an array or a control and if so - the forwards the results into wdi5 test, otherwise it doesn't (line 58).

We would like to call methods which return other objects and then check the results or query those objects deeper.

To Reproduce Just get any control which has binding and try to retrieve it using getBinding('bindingName'). We used sap.ui.table.Table control and it's binding 'rows'.

Expected behavior We should the the result object which was retrieved in UI5, currently we got the control object which method we called.

Runtime Env (please complete the following information):

vobu commented 2 years ago

thanks for bringing attention to them non-primitives return values of a $control-API method 👍 My guess is that we could resolve this pretty quickly by serializing non-primitive values in the browser scope and passing that serialized value to the Node-scope as is - any caveats @dominikfeininger?

dominikfeininger commented 2 years ago

https://webdriver.io/docs/api/browser/executeAsync/

Arguments may be any JSON-primitive, array, or JSON object. JSON objects that define a WebElement reference will be converted to the corresponding DOM element. Likewise, any WebElements in the script result will be returned to the client as WebElement JSON objects.

Guess the also counts for the returned object. Serialization not necessary but we need to remove circular structures etc..

dominikfeininger commented 2 years ago

Test:

it.only("check binding info", async () => {
        const title = await browser.asControl({ selector: { id: "container-Sample---Main--Title::NoAction.h1" } })
        const bindingInfo = await title.getBinding("text")
        expect(bindingInfo).not.toBeNull()
    })

Result: image

vobu commented 2 years ago

maybe use https://github.com/js-soft/wdi5/blob/204ce911b9ef2de295753fdc40ca5a6066add533/client-side-js/injectUI5.js#L243 to first pipe the object through before returning it?!

dominikfeininger commented 2 years ago

yep, already a todo in code ;)

https://github.com/js-soft/wdi5/blob/204ce911b9ef2de295753fdc40ca5a6066add533/client-side-js/executeControlMethod.js#L49