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 navigate with URL search parameters in a wdi5 test? (waitForUI5Options undefined error) #598

Closed gssales closed 3 months ago

gssales commented 6 months ago

I am trying to write a wdi5 test for a simple SAPUI5 webpage, but I need to change the URL parameters before running the tests. For example: the baseURL is localhost:8080/index.html, so before I run the test I want to navigate to localhost:8080/index.html?param=true.

Here's the code sample of what I tried to do:

describe("samples", () => {

    before(async () => {

        await browser.goTo('?test=param') // all these options failed
        // await wdi5.goTo('?test=param')
        // await wdi5.goTo({ sHash: '?test=param' })

    })

    it("should log", () => {
        const logger = wdi5.getLogger()
        logger.log("hello world!")
    })

    it("should retrieve a UI5 control", async () => {
        const appLocator = {
            selector: {
                controlType: "sap.m.App",
                viewName: "test_sandbox.view.App"
            }
        }

        const app = await browser.asControl(appLocator) // seems to crash around here 
        expect(app).toBeDefined()
    })
...

When I run this test, I see the URL changing but I get the following error and the test fails:

[0-0] 2024-03-21T12:55:30.125Z ERROR webdriver: Request failed with status 500 due to javascript error: javascript error: Cannot read properties of undefined (reading 'waitForUI5Options')
[0-0] JavaScript stack:
[0-0] TypeError: Cannot read properties of undefined (reading 'waitForUI5Options')
[0-0]     at eval (eval at executeAsyncScript (:447:26), <anonymous>:4:65)
[0-0]     at eval (eval at executeAsyncScript (:447:26), <anonymous>:33:8)
[0-0]     at eval (eval at executeAsyncScript (:447:26), <anonymous>:33:33)
[0-0]     at executeAsyncScript (<anonymous>:447:47)
[0-0]     at apply.selector.id (<anonymous>:462:29)
[0-0]     at callFunction (<anonymous>:341:22)
[0-0]     at <anonymous>:355:23
[0-0]     at <anonymous>:356:3
[0-0]   (Session info: chrome=122.0.6261.129)
[0-0] javascript error in "samples.should open and close Hello World dialog"
javascript error: javascript error: Cannot read properties of undefined (reading 'waitForUI5Options')
JavaScript stack:
TypeError: Cannot read properties of undefined (reading 'waitForUI5Options')
    at eval (eval at executeAsyncScript (:447:26), <anonymous>:4:65)
    at eval (eval at executeAsyncScript (:447:26), <anonymous>:33:8)
    at eval (eval at executeAsyncScript (:447:26), <anonymous>:33:33)
    at executeAsyncScript (<anonymous>:447:47)
    at apply.selector.id (<anonymous>:462:29)
    at callFunction (<anonymous>:341:22)
    at <anonymous>:355:23
    at <anonymous>:356:3
  (Session info: chrome=122.0.6261.129)
    at async clientSide_getControl (/Users/i538205/Projects/test_sandbox/node_modules/wdio-ui5-service/client-side-js/getControl.cjs:3:12)
    at async WDI5Control._getControl (file:///Users/i538205/Projects/test_sandbox/node_modules/wdio-ui5-service/src/lib/wdi5-control.ts:692:26)
    at async WDI5Control.init (file:///Users/i538205/Projects/test_sandbox/node_modules/wdio-ui5-service/src/lib/wdi5-control.ts:95:31)
    at async Browser.<anonymous> (file:///Users/i538205/Projects/test_sandbox/node_modules/wdio-ui5-service/src/lib/wdi5-bridge.ts:263:33)
[0-0] FAILED in chrome - file:///webapp/test/e2e/sample.test.ts

This project was created using the easy-ui5 generator and the npm init wdi5@latest -- --ts command.

I am using:

Can someone help me with this? How can I navigate with the URL params and achieve my tests?

Thank you

Siolto commented 5 months ago

do you have to do this manually or can you simply use the URL parameters directly in the baseUrl?

gssales commented 5 months ago

We expected to change the URL params while running the test suites. For example: test case where if language_code param in the url changes, the page language also changes.

github-actions[bot] commented 4 months ago

hey πŸ‘‹ - silence for 30 days 🀐 ... anybody? πŸ˜€

github-actions[bot] commented 3 months ago

hey πŸ‘‹ - silence for 30 days 🀐 ... anybody? πŸ˜€

github-actions[bot] commented 3 months ago

closed πŸ“΄ because silencio 🀫 since an additional 14 days after staleness πŸ“