Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: wait for the injection of wdi5 till the redirection finished #379

Merged
merged 4 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/lib/wdi5-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
10 changes: 6 additions & 4 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
}
Expand All @@ -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!")
}
Expand All @@ -53,8 +53,10 @@ 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)) {
// 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 :(")
}
Expand Down