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

How to resolve error : [wdi5] bridge was not initialized correctly #122

Closed nair-sumesh closed 2 years ago

nair-sumesh commented 2 years ago

Describe the bug Receiving below error several times at the beginning of the test code execution. My test cases passed successfully though. Could this message be resolved or suppressed.

Code

      const elem = await $('#meAreaHeaderButton')
      await elem.waitForDisplayed({ timeout: 3000 });

      const _ui5Service = require('wdio-ui5-service').default
      const wdioUI5Service = new _ui5Service()
      wdioUI5Service.injectUI5()

After this statement the error is raised several times in a row, before the actual actions/assertions are executed.

Logs/Console Output

[0-0] [wdi5] bridge was not initialized correctly
[0-0] 2022-01-25T12:55:45.974Z ERROR @wdio/utils:shim: Error: [wdi5]bridge was not initialized correctly
[0-0]     at Object.error (C:\Users\MyUser\git\MyUser\wdi5_resmon\node_modules\wdio-ui5-service\src\lib\Logger.js:77:19)
[0-0]     at Object.injectUI5 (C:\Users\MyUser\git\MyUser\wdi5_resmon\node_modules\wdio-ui5-service\src\lib\wdioUi5-index.js:283:16)
[0-0]     at processTicksAndRejections (internal/process/task_queues.js:95:5)
[0-0]     at async Service.injectUI5 (C:\Users\MyUser\git\MyUser\wdi5_resmon\node_modules\wdio-ui5-service\src\service.js:62:9)
[0-0]     at async Service.startWDI5 (C:\Users\MyUser\git\MyUser\wdi5_resmon\node_modules\wdio-ui5-service\src\service.js:49:13)
[0-0]     at async Service.before (C:\Users\MyUser\git\MyUser\wdi5_resmon\node_modules\wdio-ui5-service\src\service.js:6:9)
[0-0]     at async Promise.all (index 0)
[0-0]     at async executeHooksWithArgsShim (C:\Users\MyUser\git\MyUser\wdi5_resmon\node_modules\@wdio\utils\build\shim.js:101:20)
[0-0]     at async Runner.run (C:\Users\MyUser\git\MyUser\wdi5_resmon\node_modules\@wdio\runner\build\index.js:99:9)

Runtime Env (please complete the following information):

vobu commented 2 years ago

if you're late-injecting wdi5, with the new async notation, you need to await the injection:

await wdioUI5Service.injectUI5()

nair-sumesh commented 2 years ago

if you're late-injecting wdi5, with the new async notation, you need to await the injection:

await wdioUI5Service.injectUI5()

Thanks @vobu for the suggestion. The occurrence of the error have now reduced to one. The error is still raised as soon as the test starts.

vobu commented 2 years ago

right on, just for reference: we're having a test for this as well at https://github.com/js-soft/wdi5/blob/develop/wdio-ui5-service/test/ui5-late.test.js i'm taking the liberty to close this

cwang1221 commented 2 years ago

@nair-sumesh I met the same issue, and finally I found I missed the skipInjectUI5OnStart: true config. Example: https://github.com/js-soft/wdi5/blob/develop/wdio-ui5-service/test/wdio-ui5-late.conf.js#L99

nair-sumesh commented 2 years ago

@cwang1221 @vobu In my conf file, I have set

skipInjectUI5OnStart: true   
url: 'index.html'

and

baseUrl,

Later in my spec, I call

await browser.url(sBaseUrl); // sBaseUrl contains the entire URL path to the SAP system

const _ui5Service = require('wdio-ui5-service').default
const wdioUI5Service = new _ui5Service()
await wdioUI5Service.injectUI5()

Observations

@vobu Your help is appreciated.

dominikfeininger commented 2 years ago

@nair-sumesh do you have wdi5: { url: "index.html" ... }

in your config?

nair-sumesh commented 2 years ago

@nair-sumesh do you have wdi5: { url: "index.html" ... }

in your config?

Yes.

  wdi5: {
    screenshotPath: path.join('wdio-ui5-service', 'test', 'report', 'screenshots'),
    logLevel: 'verbose', // error | verbose | silent
    platform: 'browser', // electron, browser, android, ios
    url: 'index.html',
    deviceType: 'web',
    waitForUI5Timeout: 15000,
    skipInjectUI5OnStart: true  
  },
dominikfeininger commented 2 years ago

The flow with skipInjectUI5OnStart: true works like:

So my guess would be to set the url property to empty string "" in case you don't need it.

nair-sumesh commented 2 years ago

Thanks @dominikfeininger . This worked.