From 53e1a7e952a84825feb9b42a8a9a2684b2ff71f9 Mon Sep 17 00:00:00 2001 From: Simon Coen <32054457+Siolto@users.noreply.github.com> Date: Wed, 15 Jun 2022 21:23:22 +0200 Subject: [PATCH] feat: improved sync with ui5 core lifecycle (#278) * feat: wait till the page is done loading and then check if ui5 is present * docs: add required ui5 libraries to prerequisites * docs: describe library prerequisites in more detail --- docs/installation.md | 1 + src/lib/wdi5-bridge.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index 8a19d58b..aa8090fd 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -7,6 +7,7 @@ With `wdi5` [being a service to WebdriverIO](https://webdriver.io/docs/wdio-ui5- - UI5 app running in the browser, accessible via `http(s)://host.ext:port`. Recommended tooling for this is either the official [UI5 tooling](https://github.com/SAP/ui5-tooling) (`ui5 serve`) or some standalone http server like [`soerver`](https://github.com/vobu/soerver) or [`http-server`](https://www.npmjs.com/package/http-server). - Node.js version >= `14` (`lts/fermium`) +- If you don't provide your framework libraries via a CDN but for example via the UI5 tooling. Please don't forget to add the following two libraries (sap.base, sap.ui.test) via `ui5 add sap.base sap.ui.test` to your `.yaml` file as wdi5 requires these libraries to work properly The installation of `wdi5` and WebdriverIO can either be done by using the [Webdriver.IO `cli`](https://webdriver.io/docs/gettingstarted.html) (recommended) or manually. diff --git a/src/lib/wdi5-bridge.ts b/src/lib/wdi5-bridge.ts index 4f61e495..98e9a5b1 100644 --- a/src/lib/wdi5-bridge.ts +++ b/src/lib/wdi5-bridge.ts @@ -129,6 +129,13 @@ export async function injectUI5(config: wdi5Config) { } export async function checkForUI5Page() { + // wait till the loading finished and the state is "completed" + await browser.waitUntil(async () => { + const state = await browser.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) => { done(!!window.sap)