From 0aa98aa2740c5c255c7a38b927607e11c6921224 Mon Sep 17 00:00:00 2001 From: scoen Date: Thu, 24 Nov 2022 13:59:44 +0100 Subject: [PATCH 1/3] fix: wait for the injection of wdi5 till the redirection finished --- src/service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service.ts b/src/service.ts index 90c0a148..01a0bcf3 100644 --- a/src/service.ts +++ b/src/service.ts @@ -30,7 +30,7 @@ export default class Service implements Services.ServiceInstance { await authenticate(this._capabilities[name].capabilities["wdi5:authentication"], name) } if (!this._config.wdi5.skipInjectUI5OnStart) { - await injectUI5(this._config as wdi5Config, browser[name]) + await this.injectUI5(browser[name]) } else { Logger.warn("skipped wdi5 injection!") } @@ -40,7 +40,7 @@ export default class Service implements Services.ServiceInstance { await authenticate(this._capabilities["wdi5:authentication"]) } if (!this._config.wdi5.skipInjectUI5OnStart) { - await injectUI5(this._config as wdi5Config, browser) + await this.injectUI5(browser) } else { Logger.warn("skipped wdi5 injection!") } From c3077a42f352368a8a78e0f98cc3244bdc9b9331 Mon Sep 17 00:00:00 2001 From: scoen Date: Thu, 24 Nov 2022 15:24:14 +0100 Subject: [PATCH 2/3] fix: support multireport also in checkforui5page --- src/lib/wdi5-bridge.ts | 8 ++++---- src/service.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/wdi5-bridge.ts b/src/lib/wdi5-bridge.ts index 75fc4469..85ac0069 100644 --- a/src/lib/wdi5-bridge.ts +++ b/src/lib/wdi5-bridge.ts @@ -131,16 +131,16 @@ export async function injectUI5(config: wdi5Config, browserInstance) { return result } -export async function checkForUI5Page() { +export async function checkForUI5Page(browserInstance) { // wait till the loading finished and the state is "completed" - await browser.waitUntil(async () => { - const state = await browser.executeAsync((done) => { + await browserInstance.waitUntil(async () => { + const state = await browserInstance.executeAsync((done) => { done(document.readyState) }) return state === "complete" }) // sap in global window namespace denotes (most likely :) ) that ui5 is present - return await browser.executeAsync((done) => { + return await browserInstance.executeAsync((done) => { done(!!window.sap) }) } diff --git a/src/service.ts b/src/service.ts index 01a0bcf3..88728bb4 100644 --- a/src/service.ts +++ b/src/service.ts @@ -53,8 +53,8 @@ export default class Service implements Services.ServiceInstance { * to the injectUI5 function of the actual wdi5-bridge */ async injectUI5(browserInstance = browser) { - if (await checkForUI5Page()) { - await injectUI5(browserInstance.config as wdi5Config, browserInstance) + if (await checkForUI5Page(browserInstance)) { + await injectUI5(this._config as wdi5Config, browserInstance) } else { throw new Error("wdi5: no UI5 page/app present to work on :(") } From 243885b4ae2ec5a2434189b4cf30b641e55835b3 Mon Sep 17 00:00:00 2001 From: scoen Date: Thu, 24 Nov 2022 15:35:18 +0100 Subject: [PATCH 3/3] fix: access the config differently depending on the scenario (latInject, multiRemote) --- src/service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/service.ts b/src/service.ts index 88728bb4..0657a916 100644 --- a/src/service.ts +++ b/src/service.ts @@ -54,7 +54,9 @@ export default class Service implements Services.ServiceInstance { */ async injectUI5(browserInstance = browser) { if (await checkForUI5Page(browserInstance)) { - await injectUI5(this._config as wdi5Config, browserInstance) + // depending on the scenario (lateInject, multiRemote) we have to access the config differently + const config = this._config ? this._config : browserInstance.config + await injectUI5(config as wdi5Config, browserInstance) } else { throw new Error("wdi5: no UI5 page/app present to work on :(") }