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

call of getControl() failed because of: Error: waitAsync is already running and cannot be called again at this moment #251

Closed siddharthmlk closed 2 years ago

siddharthmlk commented 2 years ago

Hi, I am just starting with very basic test scenario like element is visible on homepage for our UI5 based web application. I am always getting [0-0] [wdi5] call of getControl() failed because of: Error: waitAsync is already running and cannot be called again at this moment [0-0] [wdi5] cpseapp--sideNavigationToggleButton has no sReplFunctionNames . I looked around the related issues and tried to run some sample test cases available here and there and they seems to work. I am not sure what exactly is missing

To Reproduce 1) I have used the below selector id from the test recorder tool image

2) Below is the test script am trying to run

describe('My CPSE application', () => {

    it('should open home page', async () => {
        const title = await browser.getTitle()
        expect(title).toEqual('Modeler');
    });
    it('open and create Template', async () => {
        expect(
            await browser.asControl({
                selector: {
                    id: "cpse---app--sideNavigationToggleButton"
                }
            }).getVisible()).toBeTruthy();

        const template_btn_key = {
            selector: {
                controlType: "sap.tnt.NavigationListItem",
                //viewId: "cpse---app",
                bindingPath: {
                    path: "/navigation/1/items/0",
                    propertyPath: "title",
                    modelName: "side"
                }
            }
        };
        // const text = await browser.asControl(template_btn_key).getText();
        // await browser.waitUntil(text === "Templates", {
        //     timeout: 60000,
        //     timeoutMsg: 'expected text is different after 60sec'
        // });
    });
});

3) wdio.conf.js

const { join } = require("path")
exports.config = {

    runner: 'local',
    specs: ['./test/specs/**/*.js' ],
    exclude: [],
    wdi5: {
        screenshotPath: join("webapp", "test", "__screenshots__"),
        screenshotsDisabled: false,
        url: "",
        logLevel: "error",
        skipInjectUI5OnStart: false,
        waitForUI5Timeout: 120000,
        platform: 'browser',
        deviceType: 'web'
    },
    maxInstances: 10,
    capabilities: [{
        maxInstances: 2,
        browserName: 'chrome',
        'goog:chromeOptions': {
            args: ['--disable-gpu', '--window-size=1400,1100', '--disable-dev-shm-usage', '--disable-browser-side-navigation',
                '--no-sandbox'
            ]
        },
        acceptInsecureCerts: true
    }],
    logLevel: 'error',
    bail: 0,
    baseUrl: 'https://internal.sap.hana.ondemand.com',
    waitforTimeout: 120000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 1,
    services: ['chromedriver', 'ui5'],
    framework: 'mocha',
    reporters: ['spec'],
    mochaOpts: {
        ui: 'bdd',
        timeout: 60000
    }
}

Logs/Console Output

$ npx wdio

Execution of 1 workers started at 2022-05-06T17:57:23.361Z

[0-0] RUNNING in chrome - C:\Users\cpse-e2e\test\specs\example.e2e.js

DevTools listening on ws://127.0.0.1:58281/devtools/browser/ee5240f7-2b1c-438d-b200-e0e2c4044a39
[34268:34288:0506/195725.861:ERROR:interface_endpoint_client.cc(665)] Message 0 rejected by interface blink.mojom.WidgetHost
[34268:34288:0506/195726.991:ERROR:interface_endpoint_client.cc(665)] Message 0 rejected by interface blink.mojom.WidgetHost
[34268:34288:0506/195734.114:ERROR:device_event_log_impl.cc(214)] [19:57:34.115] USB: usb_device_handle_win.cc:1049 Failed to read descriptor 
from node connection: A device attached to the system is not functioning. (0x1F)
[34268:34288:0506/195734.115:ERROR:device_event_log_impl.cc(214)] [19:57:34.115] USB: usb_device_handle_win.cc:1049 Failed to read descriptor 
from node connection: A device attached to the system is not functioning. (0x1F)
[34268:34288:0506/195734.115:ERROR:device_event_log_impl.cc(214)] [19:57:34.115] USB: usb_device_handle_win.cc:1049 Failed to read descriptor 
from node connection: A device attached to the system is not functioning. (0x1F)
[34268:34288:0506/195734.115:ERROR:device_event_log_impl.cc(214)] [19:57:34.116] USB: usb_device_handle_win.cc:1049 Failed to read descriptor 
from node connection: A device attached to the system is not functioning. (0x1F)
[34268:34288:0506/195734.149:ERROR:device_event_log_impl.cc(214)] [19:57:34.150] Bluetooth: bluetooth_adapter_winrt.cc:1165 RequestRadioAccessAsync failed: RadioAccessStatus::DeniedByUserWill not be able to change radio power.
[0-0] [wdi5] call of getControl() failed because of: Error: waitAsync is already running and cannot be called again at this moment
[0-0] [wdi5] cpseapp--sideNavigationToggleButton has no sReplFunctionNames
[0-0] TypeError in "My CPSE application.open and create Template"
TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
    at C:\Users\cpse-workspace\plm-e2e\node_modules\wdio-ui5-service\dist\lib\wdi5-bridge.js:165:107
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Context.<anonymous> (C:\Users\cpse-workspace\plm-e2e\test\specs\example.e2e.js:22:13)
[0-0] FAILED in chrome - C:\Users\cpse-workspace\plm-e2e\test\specs\example.e2e.js

 "spec" Reporter:
------------------------------------------------------------------
[chrome 101.0.4951.41 windows #0-0] Running: chrome (v101.0.4951.41) on windows
[chrome 101.0.4951.41 windows #0-0] Session ID: c671f4a226fde1b5b5b674bd7bd85dc7
[chrome 101.0.4951.41 windows #0-0]
[chrome 101.0.4951.41 windows #0-0] » \test\specs\example.e2e.js
[chrome 101.0.4951.41 windows #0-0] My CPSE application
[chrome 101.0.4951.41 windows #0-0]    ✓ should open home page
[chrome 101.0.4951.41 windows #0-0]    ✖ open and create Template
[chrome 101.0.4951.41 windows #0-0]
[chrome 101.0.4951.41 windows #0-0] 1 passing (32s)
[chrome 101.0.4951.41 windows #0-0] 1 failing
[chrome 101.0.4951.41 windows #0-0]
[chrome 101.0.4951.41 windows #0-0] 1) My CPSE application open and create Template
[chrome 101.0.4951.41 windows #0-0] Function.prototype.apply was called on undefined, which is a undefined and not a function
[chrome 101.0.4951.41 windows #0-0] TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function      
[chrome 101.0.4951.41 windows #0-0]     at C:\Users\cpse-workspace\plm-e2e\node_modules\wdio-ui5-service\dist\lib\wdi5-bridge.js:165:107
[chrome 101.0.4951.41 windows #0-0]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[chrome 101.0.4951.41 windows #0-0]     at async Context.<anonymous> (C:\Users\cpse-workspace\plm-e2e\test\specs\example.e2e.js:22:13) 

Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:00:38

Runtime Env (please complete the following information):

Additional context I also checked for network calls when the web application is loaded in browser, like all of them get resolved as such no pending promise to be resolved. So, am unable to understand the root cause behind it.

ThorstenSAP commented 2 years ago

Hi, Thanks for reporting the issue. We are currently investigating the issue and will come back to you shortly.

ThorstenSAP commented 2 years ago

Could you please verify, in the debugger, that the property _domId is set?

Bildschirmfoto 2022-05-09 um 15 56 46

?

ThorstenSAP commented 2 years ago

Hi @siddharthmlk, you have to add the viewName to the selector as stated here: https://js-soft.github.io/wdi5/#/locators?id=id-view

siddharthmlk commented 2 years ago

Hi,

I tried adding viewName as well, but result is still same and "domId" is coming undefined

image

ThorstenSAP commented 2 years ago

Is the project available on github? So, we could take a closer look.

siddharthmlk commented 2 years ago

plm-e2e.zip Attached zip, the baseUrl refers to internal SAP application, so won't work, here am adding screenshot of similar stuff I did using uiveri5 and it was working

image

ThorstenSAP commented 2 years ago

It seems like there is a problem with your config file. When I replaced your config file with my latest one it worked like charme. Could you re-run the setup and check the result? https://js-soft.github.io/wdi5/#/installation?id=reinitialize-setup Also you should ensure, that the baseUrl goes to your app and not to 'https://dev-pl.cfapps.sap.hana.ondemand.com'.

Bildschirmfoto 2022-05-12 um 09 18 57
siddharthmlk commented 2 years ago

Hello,

This 'https://dev-pl.cfapps.sap.hana.ondemand.com/' is actually the baseUrl which goes to our app to be tested. I am using the same locators that I was previously using with uiveri5 generated using UI5 test recorder tool but not sure what is wrong and _domId is coming undefined. Using the very minimal configuration, although if I use 'https://sapui5.hana.ondemand.com/' in baseUrl and try to interact with any control on its landing page, _domId is getting generated. See the control below

      var templateNavigationLink = await browser.asControl({
            selector: {
            controlType: "sap.tnt.NavigationListItem",
            viewName: "com.sap.clm.sl.cpse.ui.view.App",
            bindingPath: {
                path: "/navigation/1/items/0",
                propertyPath: "title",
                modelName: "side"
            }
        });
        templateNavigationLink.click();
vobu commented 2 years ago

the baseUrl redirects to a Login Page → you've implemented the Login in your wdi5 test, right?

siddharthmlk commented 2 years ago

Hi, baseUrl is referring to internal SAP application and login is implicitly handled in the browser using SSO with my certificate available locally.

vobu commented 2 years ago

ok, but yes and no 😄 yes - I get the cert-based SSO idea no - wdi5 will start an anonymous, non-profiled browser session. Your certificates won't be available in there. That's why authentication against your app will fail.

siddharthmlk commented 2 years ago

Till now chrome was using the certificates to login in non-profiled session, but I disabled the certificate manually from service registry and getting the login option during test run. Since login is non UI5 page, able to submit credentials and it redirects to SAP application. Now, using late injection of wdi5 after successful login await wdioUI5Service.injectUI5();

But post that again the story is same, _domId is coming undefined for all the controls, although same control is working fine in uiveri5

const navigationLink = await browser.asControl({
            selector: {
                controlType: "sap.tnt.NavigationListItem",
                viewName: "com.sap.clm.sl.cpse.ui.view.App",
                bindingPath: {
                    path: "/navigation/1/items/0",
                    propertyPath: "title",
                    modelName: "side"
                }
            }
        });

        navigationLink.press();   <---- _domId undefined

logs:

[0-0] RUNNING in chrome - C:\Users\plm-workspace\plm-e2e\test\specs\example.e2e.js

DevTools listening on ws://127.0.0.1:63737/devtools/browser/6567037c-e296-4afd-b98a-e4928dc8944a
[0-0] [wdi5] skipped wdi5 injection!
[59984:49732:0517/201559.498:ERROR:device_event_log_impl.cc(214)] [20:15:59.498] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[59984:49732:0517/201559.498:ERROR:device_event_log_impl.cc(214)] [20:15:59.498] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[59984:49732:0517/201559.537:ERROR:device_event_log_impl.cc(214)] [20:15:59.542] Bluetooth: bluetooth_adapter_winrt.cc:1165 RequestRadioAccessAsync failed: RadioAccessStatus::DeniedByUserWill not be able to change radio power.
[0-0] [wdi5] call of _getControl() failed because of: undefined
[0-0] [wdi5] error retrieving control: sapui.core.Icon{"src":{"regex":{"source":"sys\\-help"}}}
[0-0] [wdi5] call of _getControl() failed because of: undefined
[0-0] [wdi5] error retrieving control: comsap.clm.sl.cpse.ui.view.Appsap.tnt.NavigationListItem{"path":"/navigation/1/items/0","propertyPath":"title","modelName":"side"}
github-actions[bot] commented 2 years ago

hey 👋 - silence for 30 days 🤐 ... anybody? 😀

vobu commented 2 years ago

i sure hope that with >= v0.9.2 with the better UI5 lifecycle sync has solved this issue