Skip to content

Commit

Permalink
retrying study lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
haraprasadj committed Dec 2, 2024
1 parent f1d658e commit 5339f10
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion services/portal/discovery/discoveryQuestions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const props = require('./discoveryProps.js');
const tasks = require('./discoveryTasks.js');

const I = actor();

Expand All @@ -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
}
};
}
},
};

0 comments on commit 5339f10

Please sign in to comment.