Skip to content
Closed
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
10 changes: 9 additions & 1 deletion commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ module.exports = {
},
allowToAddAndSwitchNetwork: async () => {
await module.exports.allowToAddNetwork();
await module.exports.allowToSwitchNetwork();
await allowToSwitchNetworkIfNeeded();
return true;
},
getWalletAddress: async () => {
Expand Down Expand Up @@ -839,3 +839,11 @@ async function switchToCypressIfNotActive() {
}
return switchBackToCypressWindow;
}

async function allowToSwitchNetworkIfNeeded() {
await playwright.assignWindows().then(async () => {
if (await playwright.isNotificationOpen()) {
await module.exports.allowToSwitchNetwork();
}
});
}
10 changes: 10 additions & 0 deletions commands/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,14 @@ module.exports = {
await module.exports.waitFor(selector, page);
await page.locator(selector, { hasText: text }).waitFor();
},
async isNotificationOpen() {
await sleep(200);
let pages = browser.contexts()[0].pages();
for (const page of pages) {
if (page.url().includes('notification')) {
return true;
}
}
return false;
},
};