diff --git a/services/portal/discovery/discoveryQuestions.js b/services/portal/discovery/discoveryQuestions.js index 3d6b1865e..4c0a280d1 100644 --- a/services/portal/discovery/discoveryQuestions.js +++ b/services/portal/discovery/discoveryQuestions.js @@ -1,4 +1,5 @@ const props = require('./discoveryProps.js'); +const tasks = require('./discoveryTasks.js'); const I = actor(); @@ -12,6 +13,20 @@ module.exports = { }, isStudyFound(studyId) { - I.seeElement(props.studyLocator(studyId), 180); + const retries = 10; + for(let attempt = 1; attempt <= retries; attempt++){ + try { + I.seeElement(props.studyLocator(studyId)); + return true; + } catch (error) { + console.log(`Attempt ${attempt} to find study ${studyId} failed. Retrying ...`); + if (attempt < retries) { + tasks.goToPage(); + } else { + console.error(`Study ${studyId} not found after maximum retries.`); + throw error; // Re-throw the error after exhausting all retries + } + }; + } }, };