Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failling oData calls after using getBindingContext() #277

Closed
sebage opened this issue Jun 10, 2022 · 5 comments
Closed

Failling oData calls after using getBindingContext() #277

sebage opened this issue Jun 10, 2022 · 5 comments

Comments

@sebage
Copy link

sebage commented Jun 10, 2022

Hi,
i try to get the binding path of a certain SmartTable row, by calling getBindingContext() on a sap.m.Text element in it. After doing this, clicking the Go button of the related SmartFilterBar is causing errors like seen below.

This issue is only occurring with the call of getBindingContext(). If i remove it everything is working as expected.

[0-0] 2022-06-10T12:29:37.122Z INFO webdriver: COMMAND findElement("xpath", "//*[@id="__xmlview10--smartFilterBar-btnGo"]")
[0-0] 2022-06-10T12:29:37.122Z INFO webdriver: [POST] http://localhost:9515/session/692ade3a323cad9ec1da96a9010ef9b3/element
[0-0] 2022-06-10T12:29:37.122Z INFO webdriver: DATA {
[0-0]   using: 'xpath',
[0-0]   value: '//*[@id="__xmlview10--smartFilterBar-btnGo"]'
[0-0] }
[0-0] 2022-06-10T12:29:37.210Z INFO webdriver: RESULT { ELEMENT: '0.7987799177531782-5' }
[0-0] 2022-06-10T12:29:37.212Z INFO webdriver: COMMAND elementClick("0.7987799177531782-5")
[0-0] 2022-06-10T12:29:37.212Z INFO webdriver: [POST] http://localhost:9515/session/692ade3a323cad9ec1da96a9010ef9b3/element/0.7987799177531782-5/click
[0-0] For help, see: https://nodejs.org/en/docs/inspector
[0610/142937.274:INFO:CONSOLE(1674)] "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'requestSent')", source: https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/core-min-2.js (1674)
[0-0] › [0610/142937.429:INFO:CONSOLE(301)] "2022-06-10 14:29:37.429399 Error parsing OData messages: TypeError: Cannot read properties of undefined (reading 'messageChange') -  ", source: https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/cdm.js (301)
[0610/142937.430:INFO:CONSOLE(449)] "Uncaught TypeError: Cannot read properties of undefined (reading 'requestCompleted')", source: https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/cdm.js (449)
[0-0] ›

And then a lot of oData errors occur (this leads eventually to a timeout; all following calls to browser.asControl() are failing with an undefined error):

[0610/143259.752:INFO:CONSOLE(301)] "2022-06-10 14:32:59.752300 There are 1 open XHRs and 0 open FakeXHRs.
XHR: URL: '../App/~030622050255+0000~/odata/v2/Service/$batch' Method: 'POST' Async: 'true'
Stack:     at Object.r [as resolveStackTrace] (https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ui/test/autowaiter/_utils.js?eval:6:117)      
    at XMLHttpRequest.d (https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ui/test/autowaiter/_XHRWaiter.js?eval:6:1332)
    at XMLHttpRequest.send (https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ui/test/autowaiter/_XHRWaiter.js?eval:6:981)
    at Object.request (https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/cdm.js:211:21142)
    at E2 (https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/cdm.js:211:12554)
    at o.request (https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/cdm.js:215:927)
    at T._request (https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/core-min-3.js:2515:333)
    at f1 (https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/core-min-3.js:2442:1444)
    at https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/core-min-3.js:2442:831
    at v (https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ui/test/autowaiter/_promiseWaiter.js?eval:6:2327) -  sap.ui.test.autowaiter._XHRWaiter#hasPending", source: https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/cdm.js (301)

Code that is causing the issue:

...
        await App.iClickOnGoButton();
        var oText = await browser.asControl({
                            forceSelect: true,
                            selector: {
                                controlType: "sap.m.Text",
                                viewName: sView,
                                properties: {
                                    text: "PRODUCT_NAME-001"
                                },
                                ancestor: {
                                    controlType: "sap.m.ColumnListItem",
                                    viewName:  sView,
                                    ancestor: {
                                        id: "ViewTable",
                                        viewName: sView
                                    }
                                }
                            }
                        });
        var oSelectedRowBindingContext = await oText.getBindingContext();
        var sSelectedPath = await oSelectedRowBindingContext.sPath;
        var sSelectedRowId = sSelectedPath.split("'")[1];
        await App.iClickOnGoButton();
...
    goButton: {
        forceSelect: true,
        selector: {
            controlType: "sap.m.Button",
            viewName: sView,
            properties: {
                text: "Go"
            },
            interaction: {
                idSuffix: "BDI-content"
            }
        }
    },
...
async function _toClick(oSelector) {
    await (await (await browser.asControl(oSelector)).getWebElement()).click();
}
...
    async iClickOnGoButton() {
        await _toClick(oSelectors.goButton);
    },
  • wdio-ui5-service-version: 0.9.1
  • UI5 version: 1.102.1
  • wdio-version (output of wdio --version): 7.19.7
  • node-version (output of node --version): v16.15.0
  • OS: Windows 10
  • Browser + Version: Chrome 102.0.5005.115 (Official Build) (64-bit)
    Chrome is running in headless mode.
@vobu
Copy link
Contributor

vobu commented Jun 10, 2022

that's the first time a side effect such as a corrupted OData call is suspected to have any link to a wdi5-related call.
but I'm wondering whether #275 has something to do with that.
couple of equivalent next steps we could take:

  • provide a minimum reproducible example that helps us track down the error in more detail
  • wait for work on executeControlMethod remove of circular references changes original UI5 Object #275 to better handle circular references of returned objects from browser scope (such as the one returned by .getBindingContext())
  • rework your selector to retrieve the sap.m.ColumnListItem directly instead of doing so via an ancestor:
    (attn, all code top of my head)
    retrieve all column list items, then iterate over them to find the right one
     const allListItems = await browser.allControls(selector: {
      controlType: "sap.m.ColumnListItem",
      viewName: sView
    })
    let theOne
    for (const listItem of allListItems) {
       const text = await listItem.getText()
       if (text === "PRODUCT_NAME-001") {
         theOne = listItem
      }
    }
    or even get the all items in the list and iterate over them
    const listItems = await browser.asControl(listSelector).getItems()
    let theOne
    for (const item of listItems) {
      const text = await item.getText()
      if (text === "PRODUCT_NAME-001") {
         theOne = listItem
      }
    }
    caveat: .getItems() is slow when there's many items in the list.
    .getItems(true) is a lot faster, but "only" retrieves wdio-representations of the list items, not UI5 controls. Still, working on these might wdio-elements might be usable for you, see https://js-soft.github.io/wdi5/#/usage?id=getshorthand-conveniences → YMMV

@sebage
Copy link
Author

sebage commented Jun 13, 2022

Reworking the selector doesn't help in my case, need to access the BindingContext to get a certain Id, which is not visible on the UI.
But i was able to reproduce the initial error messages

[0610/142937.274:INFO:CONSOLE(1674)] "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'requestSent')", source: https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/core-min-2.js (1674)
[0-0] › [0610/142937.429:INFO:CONSOLE(301)] "2022-06-10 14:29:37.429399 Error parsing OData messages: TypeError: Cannot read properties of undefined (reading 'messageChange') -  ", source: https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/cdm.js (301)
[0610/142937.430:INFO:CONSOLE(449)] "Uncaught TypeError: Cannot read properties of undefined (reading 'requestCompleted')", source: https://sapui5.hana.ondemand.com/1.102.1/resources/sap/ushell/bootstrap/cdm.js (449)
[0-0] ›

in a local example, i guess these are leading to the failing oData calls at a later point.

I have attached the example: example.zip. It contains the Shopping App from https://sapui5.hana.ondemand.com/#/demoapps. And a related WDI5 test. When running the App with UI5 Serve and then executing the WDI5 tests i see the same errors as above.

From the description it could really be related to #275, maybe you can have a closer look with the example.

@vobu
Copy link
Contributor

vobu commented Jun 14, 2022

thanks for providing the minimum reproducible example! hunch is definitely towards #275
we‘re on it 🧑‍🏭

@vobu
Copy link
Contributor

vobu commented Jun 20, 2022

with #280 in and v0.9.3 being available, could you please re-check and see whether your issue was resolved?
thanks!

@sebage
Copy link
Author

sebage commented Jun 20, 2022

The issue does not occur anymore with v0.9.3

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants