Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ If your MetaMask is stuck on the loading screen, check what's happening under th
| `FAIL_ON_ERROR` | Fail a test if there are any browser console errors |
| `CYPRESS_GROUP` | [Group tests](https://docs.cypress.io/guides/guides/command-line#cypress-run-group-lt-name-gt) |
| `CI` | Boolean value indicates that tests are running from CI/CD pipeline |
| `RETRIES_SWITCH_TO_METAMASK_NOTIFICATION` | Number of retries to switch to meta mask notifications, default 50 retries |
| `RETRIES_WAIT_TO_BE_HIDDEN` | Number of retries to waitToBeHidden, default 300 retries |
| `CONFIRM_TRANSACTION_RETRIES_LIMIT` | Number of retries to confirm Metamask transaction and wait For mining, default 600 retries |

## 🚢 Release process

Expand Down
2 changes: 1 addition & 1 deletion commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ const metamask = {
.click();

let retries = 0;
const retiresLimit = 600;
const retiresLimit = process.env?.CONFIRM_TRANSACTION_RETRIES_LIMIT?? 600;

// 120 seconds
while (retries < retiresLimit) {
Expand Down
12 changes: 7 additions & 5 deletions commands/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ module.exports = {
return true;
},
async switchToMetamaskNotification() {
const maxRetries = process.env?.RETRIES_SWITCH_TO_METAMASK_NOTIFICATION??50;
const metamaskExtensionId = await module.exports.metamaskExtensionId();

let pages = await browser.contexts()[0].pages();
Expand All @@ -188,10 +189,10 @@ module.exports = {
}
}
await sleep(200);
if (retries < 50) {
if (retries < maxRetries) {
retries++;
return await module.exports.switchToMetamaskNotification();
} else if (retries >= 50) {
} else if (retries >= maxRetries) {
retries = 0;
throw new Error(
'[switchToMetamaskNotification] Max amount of retries to switch to metamask notification window has been reached. It was never found.',
Expand All @@ -200,7 +201,7 @@ module.exports = {
},
async waitFor(selector, page = metamaskWindow) {
await module.exports.waitUntilStable(page);
await page.waitForSelector(selector, { strict: false });
await page.waitForSelector(selector, { strict: false,timeout:60000 });
const element = page.locator(selector).first();
await element.waitFor();
await element.focus();
Expand Down Expand Up @@ -323,14 +324,15 @@ module.exports = {
await element.waitFor();
},
async waitToBeHidden(selector, page = metamaskWindow) {
const maxRetries = process.env?.RETRIES_WAIT_TO_BE_HIDDEN??300;
// info: waits for 60 seconds
const locator = page.locator(selector);
for (const element of await locator.all()) {
if ((await element.count()) > 0 && retries < 300) {
if ((await element.count()) > 0 && retries < maxRetries) {
retries++;
await page.waitForTimeout(200);
await module.exports.waitToBeHidden(selector, page);
} else if (retries >= 300) {
} else if (retries >= maxRetries) {
retries = 0;
throw new Error(
`[waitToBeHidden] Max amount of retries reached while waiting for ${selector} to disappear.`,
Expand Down