diff --git a/commands/metamask.js b/commands/metamask.js index aec141514..7b5f878df 100644 --- a/commands/metamask.js +++ b/commands/metamask.js @@ -35,12 +35,12 @@ module.exports = { } }, confirmWelcomePage: async () => { - await this.fixBlankPage(); + await module.exports.fixBlankPage(); await puppeteer.waitAndClick(welcomePageElements.confirmButton); return true; }, unlock: async password => { - await this.fixBlankPage(); + await module.exports.fixBlankPage(); await puppeteer.waitAndType(unlockPageElements.passwordInput, password); await puppeteer.waitAndClick(unlockPageElements.unlockButton); return true; @@ -175,15 +175,15 @@ module.exports = { if ( (await puppeteer.metamaskWindow.$(unlockPageElements.unlockPage)) === null ) { - await this.confirmWelcomePage(); - await this.importWallet(secretWords, password); - await this.changeNetwork(network); - walletAddress = await this.getWalletAddress(); + await module.exports.confirmWelcomePage(); + await module.exports.importWallet(secretWords, password); + await module.exports.changeNetwork(network); + walletAddress = await module.exports.getWalletAddress(); await puppeteer.switchToCypressWindow(); return true; } else { - await this.unlock(password); - walletAddress = await this.getWalletAddress(); + await module.exports.unlock(password); + walletAddress = await module.exports.getWalletAddress(); await puppeteer.switchToCypressWindow(); return true; } diff --git a/commands/puppeteer.js b/commands/puppeteer.js index ba23edaca..cafa18e1b 100644 --- a/commands/puppeteer.js +++ b/commands/puppeteer.js @@ -70,26 +70,26 @@ module.exports = { await page.waitForTimeout(300); }, waitAndClick: async (selector, page = metamaskWindow) => { - await this.waitFor(selector, page); + await module.exports.waitFor(selector, page); await page.evaluate( selector => document.querySelector(selector).click(), selector, ); }, waitAndType: async (selector, value, page = metamaskWindow) => { - await this.waitFor(selector, page); + await module.exports.waitFor(selector, page); const element = await page.$(selector); await element.type(value); }, waitAndGetValue: async (selector, page = metamaskWindow) => { - await this.waitFor(selector, page); + await module.exports.waitFor(selector, page); const element = await page.$(selector); const property = await element.getProperty('value'); const value = await property.jsonValue(); return value; }, waitAndSetValue: async (text, selector, page = metamaskWindow) => { - await this.waitFor(selector, page); + await module.exports.waitFor(selector, page); await page.evaluate( selector => (document.querySelector(selector).value = ''), selector, @@ -98,7 +98,7 @@ module.exports = { await page.keyboard.type(text); }, waitForText: async (selector, text, page = metamaskWindow) => { - await this.waitFor(selector, page); + await module.exports.waitFor(selector, page); await page.waitForFunction( `document.querySelector('${selector}').innerText.toLowerCase().includes('${text}')`, ); diff --git a/helpers.js b/helpers.js index f5bb2f326..e36a854d0 100644 --- a/helpers.js +++ b/helpers.js @@ -36,15 +36,15 @@ module.exports = { ); }, prepareMetamask: async () => { - const release = await this.getMetamaskReleases(); + const release = await module.exports.getMetamaskReleases(); const downloadsDirectory = path.resolve(__dirname, 'downloads'); if (!fs.existsSync(downloadsDirectory)) { fs.mkdirSync(downloadsDirectory); } const downloadDestination = path.join(downloadsDirectory, release.filename); - await this.download(release.downloadUrl, downloadDestination); + await module.exports.download(release.downloadUrl, downloadDestination); const metamaskDirectory = path.join(downloadsDirectory, 'metamask'); - await this.extract(downloadDestination, metamaskDirectory); + await module.exports.extract(downloadDestination, metamaskDirectory); return metamaskDirectory; }, };