Merge pull request #3794 from MetaMask/e2e-selector

test - e2e - prefer css selectors over xpath
This commit is contained in:
Thomas Huang 2018-03-29 12:14:33 -07:00 committed by GitHub
commit 49d27815f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 17 deletions

View File

@ -14,7 +14,7 @@ describe('Metamask popup page', function () {
const extPath = path.resolve('dist/chrome') const extPath = path.resolve('dist/chrome')
driver = buildWebDriver(extPath) driver = buildWebDriver(extPath)
await driver.get('chrome://extensions-frame') await driver.get('chrome://extensions-frame')
const elems = await driver.findElements(By.className('extension-list-item-wrapper')) const elems = await driver.findElements(By.css('.extension-list-item-wrapper'))
const extensionId = await elems[1].getAttribute('id') const extensionId = await elems[1].getAttribute('id')
await driver.get(`chrome-extension://${extensionId}/popup.html`) await driver.get(`chrome-extension://${extensionId}/popup.html`)
await delay(500) await delay(500)
@ -37,21 +37,19 @@ describe('Metamask popup page', function () {
}) })
it('should show privacy notice', async () => { it('should show privacy notice', async () => {
const privacy = await driver.findElement(By.className( const privacy = await driver.findElement(By.css('.terms-header')).getText()
'terms-header'
)).getText()
assert.equal(privacy, 'PRIVACY NOTICE', 'shows privacy notice') assert.equal(privacy, 'PRIVACY NOTICE', 'shows privacy notice')
driver.findElement(By.css( driver.findElement(By.css(
'button' 'button'
)).click() )).click()
await delay(300)
}) })
it('should show terms of use', async () => { it('should show terms of use', async () => {
await delay(300) await delay(300)
const terms = await driver.findElement(By.className( const terms = await driver.findElement(By.css('.terms-header')).getText()
'terms-header'
)).getText()
assert.equal(terms, 'TERMS OF USE', 'shows terms of use') assert.equal(terms, 'TERMS OF USE', 'shows terms of use')
await delay(300)
}) })
it('should be unable to continue without scolling throught the terms of use', async () => { it('should be unable to continue without scolling throught the terms of use', async () => {
@ -63,6 +61,7 @@ describe('Metamask popup page', function () {
'Attributions' 'Attributions'
)) ))
await driver.executeScript('arguments[0].scrollIntoView(true)', element) await driver.executeScript('arguments[0].scrollIntoView(true)', element)
await delay(300)
}) })
it('should be able to continue when scrolled to the bottom of terms of use', async () => { it('should be able to continue when scrolled to the bottom of terms of use', async () => {
@ -71,10 +70,10 @@ describe('Metamask popup page', function () {
await delay(500) await delay(500)
assert.equal(buttonEnabled, true, 'enabled continue button') assert.equal(buttonEnabled, true, 'enabled continue button')
await button.click() await button.click()
await delay(300)
}) })
it('should accept password with length of eight', async () => { it('should accept password with length of eight', async () => {
await delay(300)
const passwordBox = await driver.findElement(By.id('password-box')) const passwordBox = await driver.findElement(By.id('password-box'))
const passwordBoxConfirm = await driver.findElement(By.id('password-box-confirm')) const passwordBoxConfirm = await driver.findElement(By.id('password-box-confirm'))
const button = driver.findElement(By.css('button')) const button = driver.findElement(By.css('button'))
@ -87,16 +86,16 @@ describe('Metamask popup page', function () {
it('should show value was created and seed phrase', async () => { it('should show value was created and seed phrase', async () => {
await delay(700) await delay(700)
this.seedPhase = await driver.findElement(By.className('twelve-word-phrase')).getText() this.seedPhase = await driver.findElement(By.css('.twelve-word-phrase')).getText()
const continueAfterSeedPhrase = await driver.findElement(By.css('button')) const continueAfterSeedPhrase = await driver.findElement(By.css('button'))
await continueAfterSeedPhrase.click() await continueAfterSeedPhrase.click()
await delay(300)
}) })
it('should show lock account', async () => { it('should show lock account', async () => {
await delay(300) await driver.findElement(By.css('.sandwich-expando')).click()
await driver.findElement(By.className('sandwich-expando')).click()
await delay(500) await delay(500)
await driver.findElement(By.xpath('//*[@id="app-content"]/div/div[3]/span/div/li[2]')).click() await driver.findElement(By.css('#app-content > div > div:nth-child(3) > span > div > li:nth-child(3)')).click()
}) })
it('should accept account password after lock', async () => { it('should accept account password after lock', async () => {
@ -106,16 +105,16 @@ describe('Metamask popup page', function () {
await delay(500) await delay(500)
}) })
it('should show QR code', async () => { it('should show QR code option', async () => {
await delay(300) await delay(300)
await driver.findElement(By.className('fa-ellipsis-h')).click() await driver.findElement(By.css('.fa-ellipsis-h')).click()
await driver.findElement(By.xpath('//*[@id="app-content"]/div/div[4]/div/div/div[1]/flex-column/div[1]/div/span/i/div/div/li[2]')).click() await driver.findElement(By.css('#app-content > div > div.app-primary.from-right > div > div > div:nth-child(1) > flex-column > div.name-label > div > span > i > div > div > li:nth-child(3)')).click()
await delay(300) await delay(300)
}) })
it('should show the account address', async () => { it('should show the account address', async () => {
this.accountAddress = await driver.findElement(By.className('ellip-address')).getText() this.accountAddress = await driver.findElement(By.css('.ellip-address')).getText()
await driver.findElement(By.className('fa-arrow-left')).click() await driver.findElement(By.css('.fa-arrow-left')).click()
await delay(500) await delay(500)
}) })
}) })