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

Commit 062bda7

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

File tree

2 files changed

+72
-47
lines changed

2 files changed

+72
-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: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
console.log("Navigating to main page ...");
24+
await driver.navBack();
25+
}
26+
});
27+
28+
afterEach(async function () {
29+
if (this.currentTest.state === "failed") {
30+
await driver.logPageSource(this.currentTest.title);
31+
await driver.logScreenshot(this.currentTest.title);
32+
}
33+
});
34+
35+
after(async () => {
36+
await driver.quit();
37+
console.log("Quit driver!");
38+
});
39+
40+
it("should navigate to a ninja", async () => {
41+
const btnNinjas = await driver.findElementByText("Ninjas");
42+
await btnNinjas.click();
43+
44+
const itemMichaelangelo = await driver.findElementByText("Michaelangelo");
45+
await itemMichaelangelo.click();
46+
47+
const lblMichaelangelo = await driver.findElementByText("Ninja Michaelangelo!");
48+
await lblMichaelangelo.isDisplayed();
49+
50+
const btnBackToNinjas = await driver.findElementByText("Back to ninjas");
51+
await btnBackToNinjas.click();
52+
53+
const btnGoBackHome = await driver.findElementByText("Go back home");
54+
await btnGoBackHome.click();
55+
});
56+
57+
const styleTypes = {
58+
"inline": "styleInline",
59+
"page": "stylePage",
60+
"app": "styleApp"
61+
};
62+
63+
for (let styleType in styleTypes) {
64+
it(`should find an element with ${styleType} style applied`, async function () {
65+
const element = await driver.findElementByText(styleTypes[styleType]);
66+
const result = await driver.compareElement(element, "style");
67+
assert.isTrue(result);
68+
});
69+
}
70+
71+
const getItems = async () => { return driver.isAndroid ? await driver.findElementsByText("(Android)") : await driver.findElementsByText("(ios)"); }
72+
});

0 commit comments

Comments
 (0)