Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nativescript-appium-example.ts
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('user@test.com')
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
You can’t perform that action at this time.