This repository was archived by the owner on Aug 7, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtests.e2e-spec.ts
55 lines (44 loc) · 1.82 KB
/
tests.e2e-spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
import { assert } from "chai";
describe("sample scenario", async function () {
let driver: AppiumDriver;
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
});
afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
}
});
after(async function () {
await driver.quit();
console.log("Quit driver!");
});
it("should navigate to a ninja", async function () {
const btnNinjas = await driver.waitForElement("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]);
driver.imageHelper.options.keepOriginalImageSize = false;
driver.imageHelper.options.isDeviceSpecific = false;
const result = await driver.compareElement(element, "style");
assert.isTrue(result);
});
}
});