1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Clear input elements in e2e tests instead of using sendKeys (#8468)

This commit is contained in:
Erik Marks 2020-04-29 20:48:36 -07:00 committed by GitHub
parent 0c7269f599
commit ec20d46362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 42 deletions

View File

@ -434,17 +434,15 @@ describe('MetaMask', function () {
await driver.assertElementNotPresent(By.xpath(`//li[contains(text(), 'Data')]`)) await driver.assertElementNotPresent(By.xpath(`//li[contains(text(), 'Data')]`))
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input')) const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50)
await gasPriceInput.clear()
await gasPriceInput.sendKeys(Key.BACK_SPACE)
await driver.delay(50) await driver.delay(50)
await gasPriceInput.sendKeys('10') await gasPriceInput.sendKeys('10')
await driver.delay(50) await driver.delay(50)
await driver.delay(tinyDelayMs) await driver.delay(tinyDelayMs)
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await gasLimitInput.clear()
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys('25000') await gasLimitInput.sendKeys('25000')
@ -693,16 +691,13 @@ describe('MetaMask', function () {
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input')) const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
const gasLimitValue = await gasLimitInput.getAttribute('value') const gasLimitValue = await gasLimitInput.getAttribute('value')
assert(Number(gasLimitValue) < 100000, 'Gas Limit too high') assert(Number(gasLimitValue) < 100000, 'Gas Limit too high')
await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50)
await gasPriceInput.sendKeys(Key.BACK_SPACE) await gasPriceInput.clear()
await driver.delay(50) await driver.delay(50)
await gasPriceInput.sendKeys('10') await gasPriceInput.sendKeys('10')
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50) await gasLimitInput.clear()
await gasLimitInput.sendKeys(Key.BACK_SPACE)
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys('60001') await gasLimitInput.sendKeys('60001')
@ -954,16 +949,13 @@ describe('MetaMask', function () {
await driver.delay(regularDelayMs) await driver.delay(regularDelayMs)
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input')) const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50)
await gasPriceInput.sendKeys(Key.BACK_SPACE) await gasPriceInput.clear()
await driver.delay(50) await driver.delay(50)
await gasPriceInput.sendKeys('10') await gasPriceInput.sendKeys('10')
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50) await gasLimitInput.clear()
await gasLimitInput.sendKeys(Key.BACK_SPACE)
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys('60000') await gasLimitInput.sendKeys('60000')
@ -1060,16 +1052,13 @@ describe('MetaMask', function () {
await driver.delay(regularDelayMs) await driver.delay(regularDelayMs)
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input')) const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50)
await gasPriceInput.sendKeys(Key.BACK_SPACE) await gasPriceInput.clear()
await driver.delay(50) await driver.delay(50)
await gasPriceInput.sendKeys('10') await gasPriceInput.sendKeys('10')
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50) await gasLimitInput.clear()
await gasLimitInput.sendKeys(Key.BACK_SPACE)
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys('60001') await gasLimitInput.sendKeys('60001')

View File

@ -1,7 +1,7 @@
const assert = require('assert') const assert = require('assert')
const webdriver = require('selenium-webdriver') const webdriver = require('selenium-webdriver')
const { By, Key, until } = webdriver const { By, until } = webdriver
const { const {
tinyDelayMs, tinyDelayMs,
regularDelayMs, regularDelayMs,
@ -111,21 +111,16 @@ describe('Using MetaMask with an existing account', function () {
const gasModal = await driver.findElement(By.css('span .modal')) const gasModal = await driver.findElement(By.css('span .modal'))
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input')) const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50)
await gasPriceInput.clear()
await gasPriceInput.sendKeys(Key.BACK_SPACE)
await driver.delay(50)
await gasPriceInput.sendKeys(Key.BACK_SPACE)
await driver.delay(50) await driver.delay(50)
await gasPriceInput.sendKeys('10') await gasPriceInput.sendKeys('10')
await driver.delay(50) await driver.delay(50)
await driver.delay(tinyDelayMs) await driver.delay(tinyDelayMs)
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50)
await gasLimitInput.clear()
await driver.delay(50)
await gasLimitInput.sendKeys('25000') await gasLimitInput.sendKeys('25000')
await driver.delay(1000) await driver.delay(1000)
@ -154,9 +149,8 @@ describe('Using MetaMask with an existing account', function () {
await driver.delay(regularDelayMs) await driver.delay(regularDelayMs)
const inputAmount = await driver.findElement(By.css('.unit-input__input')) const inputAmount = await driver.findElement(By.css('.unit-input__input'))
await inputAmount.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50) await inputAmount.clear()
await inputAmount.sendKeys(Key.BACK_SPACE)
await driver.delay(50) await driver.delay(50)
await inputAmount.sendKeys('2.2') await inputAmount.sendKeys('2.2')
@ -166,20 +160,16 @@ describe('Using MetaMask with an existing account', function () {
const gasModal = await driver.findElement(By.css('span .modal')) const gasModal = await driver.findElement(By.css('span .modal'))
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input')) const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50)
await gasPriceInput.sendKeys(Key.BACK_SPACE) await gasPriceInput.clear()
await driver.delay(50)
await gasPriceInput.sendKeys(Key.BACK_SPACE)
await driver.delay(50) await driver.delay(50)
await gasPriceInput.sendKeys('8') await gasPriceInput.sendKeys('8')
await driver.delay(50) await driver.delay(50)
await driver.delay(tinyDelayMs) await driver.delay(tinyDelayMs)
await driver.delay(50) await driver.delay(50)
await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
await driver.delay(50)
await gasLimitInput.clear()
await driver.delay(50)
await gasLimitInput.sendKeys('100000') await gasLimitInput.sendKeys('100000')
await driver.delay(1000) await driver.delay(1000)