From fc9a100e86638750675cbe71946dc405c411df7a Mon Sep 17 00:00:00 2001 From: Christian Darsow Date: Mon, 27 Nov 2023 11:05:30 +0100 Subject: [PATCH] Add wait function --- page-objects/pages/NWSAddEditNewsPage.js | 1 + runtime/helpers/waitHelpers.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/page-objects/pages/NWSAddEditNewsPage.js b/page-objects/pages/NWSAddEditNewsPage.js index db08034f..208aa75e 100644 --- a/page-objects/pages/NWSAddEditNewsPage.js +++ b/page-objects/pages/NWSAddEditNewsPage.js @@ -21,6 +21,7 @@ async function setNewsTitle(newsTitle) { async function setNewsContent(newsContent) { await elementHelpers.click(contentField); await waitHelpers.waitAndSetValue(contentField, newsContent); + await waitHelpers.wait(1000); } async function setNewsPublishDate(newsDate) { diff --git a/runtime/helpers/waitHelpers.js b/runtime/helpers/waitHelpers.js index f5237c86..9145aab0 100644 --- a/runtime/helpers/waitHelpers.js +++ b/runtime/helpers/waitHelpers.js @@ -19,8 +19,8 @@ const titleTimeout = 30000; const shortInterval = 50; const mediumInterval = 100; const pageLoadLegacy = "//dl[@role='navigation']"; -const pageLoaded = "div.topbar"; -const pageNotLoaded = "div#nuxt-loading"; +const pageLoaded = 'div.topbar'; +const pageNotLoaded = 'div#nuxt-loading'; async function waitUntilElementIsPresent(selectorOrElement, timeout = elementIsPresentTimeout) { let element = await sharedHelpers.getElement(selectorOrElement); @@ -203,11 +203,11 @@ async function waitUntilNuxtClientLoads(timeout = pageLoadingTimeout) { await waitUntilPageLoads(); while (!nuxtPageLoad) { await waitUntilElementIsNotPresent(pageNotLoaded); - if (await waitUntilElementIsPresent(pageLoaded)){ + if (await waitUntilElementIsPresent(pageLoaded)) { nuxtPageLoad = true; - }else { + } else { await driver.refresh(); - if(await waitUntilElementIsPresent(pageLoaded)){ + if (await waitUntilElementIsPresent(pageLoaded)) { nuxtPageLoad = true; } } @@ -333,6 +333,10 @@ async function waitUntilPageTitleEquals(expectedTitle, timeout = titleTimeout) { } } +async function wait(timeout = setValueTimeout) { + await driver.pause(timeout); +} + module.exports = { waitUntilElementIsPresent, waitUntilElementIsNotPresent, @@ -354,4 +358,5 @@ module.exports = { waitUntilPageTitleContains, waitUntilPageTitleEquals, waitUntilNuxtClientLoads, + wait, };