Skip to content

Commit

Permalink
feat: improved sync with ui5 core lifecycle (#278)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Siolto committed Jun 15, 2022
1 parent 7321b5d commit 53e1a7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/installation.md
Expand Up @@ -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.

Expand Down
7 changes: 7 additions & 0 deletions src/lib/wdi5-bridge.ts
Expand Up @@ -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)
Expand Down

0 comments on commit 53e1a7e

Please sign in to comment.