Skip to content

Commit

Permalink
fix: add timeout to clickButton
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jun 10, 2022
1 parent 3a8ddbe commit 452178c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/e2e/testBatteries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const Units = {

async function clickButton(page, selectionData) {
const selector=typeof selectionData=="object"&&selectionData.$?selectionData.$:"button";

const start=Date.now();
return new Promise<void>((rr) => {
const findAndClickButton = async () => {
const buttons = await page.$$(selector);
Expand All @@ -144,7 +144,8 @@ async function clickButton(page, selectionData) {
}
console.log("Looking for button ...", selectionData);

setTimeout(() => findAndClickButton(), 1000);
if(Date.now()-start>1*60*1000) rr(); // timeout after 1 minute
else setTimeout(() => findAndClickButton(), 1000);
}
setTimeout(() => findAndClickButton(), 1000);
});
Expand Down

0 comments on commit 452178c

Please sign in to comment.