Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions demo/AngularApp/e2e/sample.e2e-spec.ts

This file was deleted.

72 changes: 72 additions & 0 deletions demo/AngularApp/e2e/tests.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
import { assert } from "chai";

describe("sample scenario", () => {
const defaultWaitTime = 5000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

let driver: AppiumDriver;

before(async () => {
driver = await createDriver();
});

beforeEach(async function () {
try {
const items = await getItems();
} catch (err) {
try {
const lblNinjas = await driver.findElementByText("Ninjas!");
}
catch (err) {
console.log("Navigating to ninjas page ...");
await driver.navBack();
}
console.log("Navigating to main page ...");
await driver.navBack();
}
});

afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logPageSource(this.currentTest.title);
await driver.logScreenshot(this.currentTest.title);
}
});

after(async () => {
await driver.quit();
console.log("Quit driver!");
});

it("should navigate to a ninja", async () => {
const btnNinjas = await driver.findElementByText("Ninjas");
await btnNinjas.click();

const itemMichaelangelo = await driver.findElementByText("Michaelangelo");
await itemMichaelangelo.click();

const lblMichaelangelo = await driver.findElementByText("Ninja Michaelangelo!");
await lblMichaelangelo.isDisplayed();

const btnBackToNinjas = await driver.findElementByText("Back to ninjas");
await btnBackToNinjas.click();

const btnGoBackHome = await driver.findElementByText("Go back home");
await btnGoBackHome.click();
});

const styleTypes = {
"inline": "styleInline",
"page": "stylePage",
"app": "styleApp"
};

for (let styleType in styleTypes) {
it(`should find an element with ${styleType} style applied`, async function () {
const element = await driver.findElementByText(styleTypes[styleType]);
const result = await driver.compareElement(element, "style");
assert.isTrue(result);
});
}

const getItems = async () => { return driver.isAndroid ? await driver.findElementsByText("(Android)") : await driver.findElementsByText("(ios)"); }
});