Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 85496d5

Browse files
vchimevvchimev
vchimev
authored and
vchimev
committed
test(AngularApp): update demo tests
1 parent 5539ddb commit 85496d5

File tree

2 files changed

+73
-47
lines changed

2 files changed

+73
-47
lines changed

demo/AngularApp/e2e/sample.e2e-spec.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

demo/AngularApp/e2e/tests.e2e-spec.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
2+
import { assert } from "chai";
3+
4+
describe("sample scenario", () => {
5+
const defaultWaitTime = 5000;
6+
let driver: AppiumDriver;
7+
8+
before(async () => {
9+
driver = await createDriver();
10+
});
11+
12+
beforeEach(async function () {
13+
try {
14+
const items = await getItems();
15+
} catch (err) {
16+
try {
17+
const lblNinjas = await driver.findElementByText("Ninjas!");
18+
}
19+
catch (err) {
20+
console.log("Navigating to ninjas page ...");
21+
await driver.navBack();
22+
// ..
23+
}
24+
console.log("Navigating to main page ...");
25+
await driver.navBack();
26+
}
27+
});
28+
29+
afterEach(async function () {
30+
if (this.currentTest.state === "failed") {
31+
await driver.logPageSource(this.currentTest.title);
32+
await driver.logScreenshot(this.currentTest.title);
33+
}
34+
});
35+
36+
after(async () => {
37+
await driver.quit();
38+
console.log("Quit driver!");
39+
});
40+
41+
it("should navigate to a ninja", async () => {
42+
const btnNinjas = await driver.findElementByText("Ninjas");
43+
await btnNinjas.click();
44+
45+
const itemMichaelangelo = await driver.findElementByText("Michaelangelo");
46+
await itemMichaelangelo.click();
47+
48+
const lblMichaelangelo = await driver.findElementByText("Ninja Michaelangelo!");
49+
await lblMichaelangelo.isDisplayed();
50+
51+
const btnBackToNinjas = await driver.findElementByText("Back to ninjas");
52+
await btnBackToNinjas.click();
53+
54+
const btnGoBackHome = await driver.findElementByText("Go back home");
55+
await btnGoBackHome.click();
56+
});
57+
58+
const styleTypes = {
59+
"inline": "styleInline",
60+
"page": "stylePage",
61+
"app": "styleApp"
62+
};
63+
64+
for (let styleType in styleTypes) {
65+
it(`should find an element with ${styleType} style applied`, async function () {
66+
const element = await driver.findElementByText(styleTypes[styleType]);
67+
const result = await driver.compareElement(element, "style");
68+
assert.isTrue(result);
69+
});
70+
}
71+
72+
const getItems = async () => { return driver.isAndroid ? await driver.findElementsByText("(Android)") : await driver.findElementsByText("(ios)"); }
73+
});

0 commit comments

Comments
 (0)