-
-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathbutton.js
More file actions
68 lines (58 loc) · 1.94 KB
/
Copy pathbutton.js
File metadata and controls
68 lines (58 loc) · 1.94 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
const chai = require("chai");
const nsAppium = require("nativescript-dev-appium");
const examples = require("./examples");
describe("button scenarios", () => {
const button = examples.examples.button;
let driver;
let index = 0;
let example;
before(async () => {
driver = await nsAppium.createDriver();
const mainPageBtn = await driver.findElementByText(button.baseExampleName);
await mainPageBtn.click();
});
beforeEach(async () => {
example = button.examples[index];
const btnTap = await driver.findElementByText(example);
await btnTap.click();
index++;
});
afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
}
await driver.navBack();
});
after(async () => {
await driver.navBack();
})
const findButton = async () => {
const btn = await driver.findElementByClassName(driver.locators.button);
return btn;
}
it(`Basics`, async () => {
const btn = await findButton();
await btn.click();
await btn.click();
await btn.click();
const text = 'TAPPED 3 TIMES';
const btnText = await btn.text();
chai.assert.isTrue(text === btnText);
});
it(`Code-Behind`, async () => {
const btn = await findButton();
await btn.click();
const text = 'My newly created button';
const dialog = await driver.findElementByText(text, "contains");
chai.assert.isTrue(await dialog.isDisplayed());
await (await driver.findElementByText("OK", "contains")).tapCenter();
});
it(`Styling`, async () => {
const btn = await findButton();
await btn.click();
await btn.click();
const text = 'TAP ME!';
const btnText = await btn.text();
chai.assert.isTrue(btnText.includes(text));
});
});