Speed up page opening and fix timeout errors on remix page opening in beta e2e tests.

feature/default_network_editable
Dan 7 years ago
parent 07970b7cfa
commit bdf9cd8e3a
  1. 14
      test/e2e/beta/helpers.js
  2. 25
      test/e2e/beta/metamask-beta-ui.spec.js

@ -2,6 +2,7 @@ const fs = require('fs')
const mkdirp = require('mkdirp') const mkdirp = require('mkdirp')
const pify = require('pify') const pify = require('pify')
const {until} = require('selenium-webdriver') const {until} = require('selenium-webdriver')
const { delay } = require('../func')
const testContract = ` const testContract = `
pragma solidity ^0.4.0; pragma solidity ^0.4.0;
@ -37,6 +38,7 @@ module.exports = {
verboseReportOnFailure, verboseReportOnFailure,
findElement, findElement,
findElements, findElements,
openNewPage,
testContract, testContract,
} }
@ -93,3 +95,15 @@ async function findElement (driver, by, timeout = 10000) {
async function findElements (driver, by, timeout = 10000) { async function findElements (driver, by, timeout = 10000) {
return driver.wait(until.elementsLocated(by), timeout) return driver.wait(until.elementsLocated(by), timeout)
} }
async function openNewPage (driver, url) {
await driver.executeScript('window.open()')
await delay(1000)
const handles = await driver.getAllWindowHandles()
const lastHandle = handles.pop()
await driver.switchTo().window(lastHandle)
await driver.get(url)
await delay(1000)
}

@ -17,6 +17,7 @@ const {
loadExtension, loadExtension,
verboseReportOnFailure, verboseReportOnFailure,
testContract, testContract,
openNewPage,
} = require('./helpers') } = require('./helpers')
describe('MetaMask', function () { describe('MetaMask', function () {
@ -385,11 +386,13 @@ describe('MetaMask', function () {
describe('Send ETH from Faucet', () => { describe('Send ETH from Faucet', () => {
it('starts a send transaction inside Faucet', async () => { it('starts a send transaction inside Faucet', async () => {
await driver.executeScript('window.open("https://faucet.metamask.io")') await openNewPage(driver, 'https://faucet.metamask.io')
await delay(waitingNewPageDelayMs)
const [extension, faucet] = await driver.getAllWindowHandles() const [extension, faucet] = await driver.getAllWindowHandles()
await driver.switchTo().window(faucet) await driver.switchTo().window(faucet)
const faucetPageTitle = await findElement(driver, By.css('.container-fluid'))
await driver.wait(until.elementTextMatches(faucetPageTitle, /MetaMask/))
await delay(regularDelayMs) await delay(regularDelayMs)
const send1eth = await findElement(driver, By.xpath(`//button[contains(text(), '10 ether')]`), 14000) const send1eth = await findElement(driver, By.xpath(`//button[contains(text(), '10 ether')]`), 14000)
@ -417,11 +420,10 @@ describe('MetaMask', function () {
describe('Deploy contract and call contract method from Remix', () => { describe('Deploy contract and call contract method from Remix', () => {
it('writes a contract to remix', async () => { it('writes a contract to remix', async () => {
await driver.executeScript('window.open("https://remix.ethereum.org/")') await openNewPage(driver, 'https://remix.ethereum.org/')
await delay(waitingNewPageDelayMs)
const [extension, remix] = await driver.getAllWindowHandles() const byFilePanel = By.css('#filepanel')
await driver.switchTo().window(remix) await driver.wait(until.elementLocated(byFilePanel))
const newContractButton = await findElement(driver, By.css('.fa-plus-circle')) const newContractButton = await findElement(driver, By.css('.fa-plus-circle'))
await newContractButton.click() await newContractButton.click()
@ -521,11 +523,9 @@ describe('MetaMask', function () {
describe('Add a custom token from TokenFactory', () => { describe('Add a custom token from TokenFactory', () => {
it('creates a new token', async () => { it('creates a new token', async () => {
await driver.executeScript('window.open("https://tokenfactory.surge.sh/#/factory")') openNewPage(driver, 'https://tokenfactory.surge.sh/#/factory')
await delay(waitingNewPageDelayMs)
const [extension, tokenFactory] = await driver.getAllWindowHandles() const [extension, tokenFactory] = await driver.getAllWindowHandles()
await driver.switchTo().window(tokenFactory)
const [ const [
totalSupply, totalSupply,
tokenName, tokenName,
@ -651,11 +651,10 @@ describe('MetaMask', function () {
describe('Send a custom token from TokenFactory', () => { describe('Send a custom token from TokenFactory', () => {
let gasModal let gasModal
it('sends an already created token', async () => { it('sends an already created token', async () => {
await driver.executeScript(`window.open("https://tokenfactory.surge.sh/#/token/${tokenAddress}")`) openNewPage(driver, `https://tokenfactory.surge.sh/#/token/${tokenAddress}`)
await delay(waitingNewPageDelayMs)
const [extension, tokenFactory] = await driver.getAllWindowHandles() const [extension, tokenFactory] = await driver.getAllWindowHandles()
await driver.switchTo().window(tokenFactory)
const [ const [
transferToAddress, transferToAddress,
transferToAmount, transferToAmount,

Loading…
Cancel
Save