This repository was archived by the owner on Aug 28, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.e2e.ts
40 lines (34 loc) · 1.57 KB
/
test.e2e.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
import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
import { ImageOptions } from "nativescript-dev-appium/lib/image-options";
import { assert } from "chai";
describe("scenario simple", () => {
const defaultWaitTime = 5000;
let driver: AppiumDriver;
before(async () => {
driver = await createDriver();
});
after(async () => {
await driver.quit();
console.log("Driver quits!");
});
afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logScreenshot(this.currentTest.title);
}
});
it("should find an element by text", async () => {
// case insesitive search by text for android
const tapButton = await driver.findElementByText("TAP");
await tapButton.click();
const displayMsg = "41 taps left";
const messageLabel = await driver.findElementByText(displayMsg, SearchOptions.contains);
assert.equal(await messageLabel.text(), displayMsg, "You have a problem. Probably the binding is not working!");
});
it("should find an element by type", async () => {
const tapButton = await driver.findElementByClassName(driver.locators.button);
await tapButton.tap();
const messageLabel = await driver.findElementByText("40 taps left", SearchOptions.contains);
const isDisplayMessageCorrect = await driver.compareScreen("hello-world-display.png", 3, 10, ImageOptions.pixel);
assert.isTrue(isDisplayMessageCorrect, "Look at hello-world-display-diif.png");
});
});