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

How to navigate with URL search parameters in a wdi5 test? (waitForUI5Options undefined error) #598

Open
gssales opened this issue Mar 21, 2024 · 4 comments
Labels

Comments

@gssales
Copy link

gssales commented Mar 21, 2024

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:

  • npm v9.8.1
  • node v18.18.2
  • wdi5 v2.0.6
  • wdio v8.34.1

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

Thank you

@Siolto
Copy link
Collaborator

Siolto commented Mar 26, 2024

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

@gssales
Copy link
Author

gssales commented Mar 26, 2024

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.

Copy link

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

@github-actions github-actions bot added the stale label Apr 26, 2024
@vobu vobu removed the stale label Apr 26, 2024
Copy link

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

@github-actions github-actions bot added the stale label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants