Skip to content

Commit

Permalink
g
Browse files Browse the repository at this point in the history
Signed-off-by: Anan Zhuang <[email protected]>
  • Loading branch information
ananzh committed Nov 15, 2023
1 parent ed0c6f6 commit 166ab53
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/functional/apps/management/_scripted_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,28 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.discover.clickTableHeaderListItem('@timestamp', 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.find(`dataGridHeaderCell-${scriptedPainlessFieldName}`);
const TIMEOUT = 300000; // e.g., 30 seconds
const RETRY_INTERVAL = 5000; // e.g., 5 seconds

// Start time
const startTime = new Date().getTime();

let found = false;
let element;

while (new Date().getTime() - startTime < TIMEOUT && !found) {
try {
element = await testSubjects.find(`dataGridHeaderCell-${scriptedPainlessFieldName}`);
found = true; // If the element is found, exit the loop
} catch (error) {
// Wait for the retry interval before the next attempt
await new Promise((resolve) => setTimeout(resolve, RETRY_INTERVAL));
}
}

if (!found) {
throw new Error(`Element ${element} not found within ${TIMEOUT / 1000} seconds`);
}
await testSubjects.click(`dataGridHeaderCell-${scriptedPainlessFieldName}`);
await PageObjects.discover.clickTableHeaderListItem(scriptedPainlessFieldName, 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down

0 comments on commit 166ab53

Please sign in to comment.