Last active
January 5, 2019 19:33
-
-
Save jeremypele/1dcb3ad317082351a28d5ac0b293cea8 to your computer and use it in GitHub Desktop.
nativescript-appium-example.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AppiumDriver, createDriver, SearchOptions } from 'nativescript-dev-appium' | |
import { runType } from 'nativescript-dev-appium/lib/parser' | |
import { Direction } from 'nativescript-dev-appium/lib/direction' | |
import { assert } from 'chai' | |
const isAndroid: string = runType.includes('android') | |
describe('E2E Specs', () => { | |
let driver: AppiumDriver | |
before(async () => (driver = await createDriver())) | |
after(async () => await driver.quit()) | |
it('displays the logout screen', async () => { | |
// Image verification | |
await driver.driver.sleep(2500) // animation | |
assert.isTrue(await driver.compareScreen('homepage-logged-out')) | |
}) | |
/* | |
* Login | |
*/ | |
describe('Login Page', async () => { | |
it('logins user', async () => { | |
const usernameField = await driver.driver.waitForElementByAccessibilityId('loginEmailInput') | |
await usernameField.click().sendKeys('[email protected]') | |
const passwordField = await driver.driver.waitForElementByAccessibilityId('loginPasswordInput') | |
await passwordField.click().sendKeys('password') | |
const submitBtn = await driver.driver.waitForElementByAccessibilityId('loginFormSubmit') | |
await submitBtn.click() | |
// Image verification | |
await driver.driver.sleep(3000) // animation | |
const homeLogo = await driver.findElementByAccessibilityId('homeLogo') | |
assert.isTrue(await driver.compareElement(homeLogo, 'home-logo')) | |
}) | |
}) | |
/* | |
* Reservations List | |
*/ | |
describe('Reservations List', async () => { | |
before(async () => { | |
const reservationsBtn = await driver.findElementByAccessibilityId('navReservationsLink') | |
await reservationsBtn.click() | |
}) | |
after(async () => { | |
const backBtn = await driver.findElementByText('Back', SearchOptions.contains) | |
await backBtn.click() | |
}) | |
it('list a reservation', async () => { | |
// Image verification | |
await driver.driver.sleep(3000) // animation | |
assert.isTrue(await driver.compareScreen('reservations-list')) | |
}) | |
describe('Show page', async () => { | |
before(async () => { | |
const reservationShowLink = await driver.findElementByText( | |
'Test Club', | |
SearchOptions.exact | |
) | |
await reservationShowLink.click() | |
}) | |
after(async () => { | |
const backBtn = await driver.findElementByText('Back', SearchOptions.contains) | |
await backBtn.click() | |
const backBtn2 = await driver.findElementByText('Back', SearchOptions.exact) | |
await backBtn2.click() | |
}) | |
it('shows the reservation detail', async () => { | |
// Image verification | |
await driver.driver.sleep(3000) // animation | |
assert.isTrue(await driver.compareScreen('reservations-show')) | |
}) | |
it('opens the detailled receipt', async () => { | |
const reservationReceiptLink = await driver.findElementByAccessibilityId( | |
'reservationReceiptLink' | |
) | |
await reservationReceiptLink.click() | |
// Image verification | |
await driver.driver.sleep(3000) // animation | |
assert.isTrue(await driver.compareScreen('reservations-show-receipt')) | |
}) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment