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

TypeError: browserInstance.getUI5Version is not a function #351

Closed sangeeta298 closed 2 years ago

sangeeta298 commented 2 years ago

I am trying out wdi5 and it works fine on my local system but when I execute the tests in jenkins, I get the below error:

13:10:26 TypeError: browserInstance.getUI5Version is not a function 13:10:26 at /home/jenkins/agent/workspace/nce-Test_flex-tests_wdio-vs-wdi5/node_modules/wdio-ui5-service/dist/lib/wdi5-bridge.js:226:58 13:10:26 at step (/home/jenkins/agent/workspace/nce-Test_flex-tests_wdio-vs-wdi5/node_modules/wdio-ui5-service/dist/lib/wdi5-bridge.js:56:23) 13:10:26 at Object.next (/home/jenkins/agent/workspace/nce-Test_flex-tests_wdio-vs-wdi5/node_modules/wdio-ui5-service/dist/lib/wdi5-bridge.js:37:53) 13:10:26 at /home/jenkins/agent/workspace/nce-Test_flex-tests_wdio-vs-wdi5/node_modules/wdio-ui5-service/dist/lib/wdi5-bridge.js:31:71 13:10:26 at new Promise (\<anonymous>) 13:10:26 at __awaiter (/home/jenkins/agent/workspace/nce-Test_flex-tests_wdio-vs-wdi5/node_modules/wdio-ui5-service/dist/lib/wdi5-bridge.js:27:12) 13:10:26 at injectUI5 (/home/jenkins/agent/workspace/nce-Test_flex-tests_wdio-vs-wdi5/node_modules/wdio-ui5-service/dist/lib/wdi5-bridge.js:219:12) 13:10:26 at Service.\<anonymous> (/home/jenkins/agent/workspace/nce-Test_flex-tests_wdio-vs-wdi5/node_modules/wdio-ui5-service/dist/service.js:130:74) 13:10:26 at step (/home/jenkins/agent/workspace/nce-Test_flex-tests_wdio-vs-wdi5/node_modules/wdio-ui5-service/dist/service.js:33:23) 13:10:26 at Object.next (/home/jenkins/agent/workspace/nce-Test_flex-tests_wdio-vs-wdi5/node_modules/wdio-ui5-service/dist/service.js:14:53)

I have added below in wdi5.conf.js:

wdi5: { screenshotPath: require("path").join("WDI5Tests","screenshots"), screenshotsDisabled: false, logLevel: "verbose", platform: 'browser', url: "", deviceType: 'web', skipInjectUI5OnStart: true, waitForUI5Timeout: 1000 60 60 //15000 },

Initially I saw page crashes in jenkins and I added additional arguments to chrome capabilities:

browserName: 'chrome', "goog:chromeOptions": { args: [ "--window-size=1440,800", "--headless", "--no-sandbox","--disable-dev-shm-usage", //to avoid page crash onPremise: https://svdoscience.com/2021-03-17/fix-session-deleted-page-crash-selenium-grid-chrome-docker "--auto-open-devtools-for-tabs" ] },

after login, I inject ui5 manually:

const { default: _ui5Service } = require("wdio-ui5-service"); const ui5Service = new _ui5Service(); ... await ui5Service.injectUI5();

I am using pageObjects, and I use below way to get UI5 controls:

get textVmName() { // return ($('[id="vm-text"][role="heading"]')); return browser.asControl({ selector: { id: /vm-text/, controlType: "sap.m.Title" } }); }

In jenkins console log, I also see below error for every control:

TypeError: browser.asControl is not a function

In package.json, I have below devdependencies among others:

"devDependencies": { "@wdio/cli": "^7.20.4", "@wdio/junit-reporter": "^7.20.3", "@wdio/local-runner": "^7.20.4", "@wdio/devtools-service": "^7.20.3", "@wdio/mocha-framework": "^7.20.3", "@wdio/spec-reporter": "^7.20.3", "chromedriver": "latest", "mocha-junit-reporter": "^2.0.2", "wdio-chromedriver-service": "latest", "wdio-ui5-service": "latest", "@wdio/sync": "^7.20.4", "geckodriver": "^3.0.1", "wdio-geckodriver-service": "^2.1.2", "wdio-safaridriver-service": "^1.1.0", }

In jenkins I have below versions of node and npm:

13:09:00 [Pipeline] sh 13:09:01 + node -v 13:09:01 v14.19.0 13:09:01 [Pipeline] sh 13:09:02 + npm -v 13:09:02 8.5.3 All works fine locally but in jenkins wdi5 tests break. Could someone help here?

Siolto commented 2 years ago

Hi @sangeeta298,

to me it sounds like that wdi5 is not properly injected in the pipeline. Is there some additional logging output from wdi5 before the TypeError occurs you can share with us?

Regards, Simon

sangeeta298 commented 2 years ago

Hi @Siolto,

I could not find any additional logs from wdi5. Wdi5.logLevel is set to verbose and on npx wdio run wdi5.conf.js, I directly get the error:

Execution of 1 workers started at 2022-10-04T10:57:50.308Z

[0-0] RUNNING in chrome - /WDI5Tests/test/vm.e2e.js [0-0] TypeError in "On Premise: Enduser.Login to TestApp (URL: ).should late inject UI5" TypeError: browserInstance.getUI5Version is not a function at /node_modules/wdio-ui5-service/dist/lib/wdi5-bridge.js:226:58

....and multiple TypeError: browser.asControl is not a function

In the test, the login on non-UI5 page works fine. After that opening of UI5 page and checking the title also works fine. The error occurs during the late injection: await ui5Service.injectUI5();

Best regards, Sangeeta

Siolto commented 2 years ago

After investigating further with @sangeeta298 we found that the baseUrl has to be something valid e.g. google.com. If we paste something invalid like abc and we programmatically navigate to the correct URL the wdi5 runtime breaks for some reasons.

Documentation should be written for that.