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

Commit d3b5cab

Browse files
SvetoslavTsenovAlexander Vakrilov
authored and
Alexander Vakrilov
committed
test: update tests to ns-dev-appium v6 (#969)
1 parent 994d6a2 commit d3b5cab

File tree

11 files changed

+18
-293
lines changed

11 files changed

+18
-293
lines changed

demo/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ tsconfig.aot.json
1616
vendor.js
1717
vendor.ts
1818

19-
tsconfig.esm.json
19+
tsconfig.esm.json
20+
mochawesome-report

demo/AngularApp/.vscode/launch.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
"999999",
1717
"--colors",
1818
"--opts",
19-
"./e2e/config/mocha.opts",
20-
"--runType",
21-
"android23",
22-
"--reuseDevice"
23-
// "${workspaceFolder}/test"
19+
"../config/mocha.opts",
20+
"android"
2421
],
2522
"internalConsoleOptions": "openOnSessionStart"
2623
},

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

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
1-
import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
1+
import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
22
import { assert } from "chai";
33

44
describe("sample scenario", async function () {
55
let driver: AppiumDriver;
66

77
before(async function () {
8+
nsCapabilities.testReporter.context = this;
89
driver = await createDriver();
910
});
1011

11-
beforeEach(async function () {
12-
try {
13-
const items = await getItems();
14-
} catch (err) {
15-
try {
16-
const lblNinjas = await driver.findElementByText("Ninjas!");
17-
}
18-
catch (err) {
19-
console.log("Navigating to ninjas page ...");
20-
await driver.navBack();
21-
}
22-
console.log("Navigating to main page ...");
23-
await driver.navBack();
24-
}
25-
});
26-
2712
afterEach(async function () {
2813
if (this.currentTest.state === "failed") {
2914
await driver.logTestArtifacts(this.currentTest.title);
@@ -36,7 +21,7 @@ describe("sample scenario", async function () {
3621
});
3722

3823
it("should navigate to a ninja", async function () {
39-
const btnNinjas = await driver.findElementByText("Ninjas");
24+
const btnNinjas = await driver.waitForElement("Ninjas");
4025
await btnNinjas.click();
4126

4227
const itemMichaelangelo = await driver.findElementByText("Michaelangelo");
@@ -61,10 +46,10 @@ describe("sample scenario", async function () {
6146
for (let styleType in styleTypes) {
6247
it(`should find an element with ${styleType} style applied`, async function () {
6348
const element = await driver.findElementByText(styleTypes[styleType]);
49+
driver.imageHelper.options.keepOriginalImageSize = false;
50+
driver.imageHelper.options.isDeviceSpecific = false;
6451
const result = await driver.compareElement(element, "style");
6552
assert.isTrue(result);
6653
});
6754
}
68-
69-
const getItems = async function () { return driver.isAndroid ? await driver.findElementsByText("(Android)") : await driver.findElementsByText("(ios)"); }
7055
});

demo/AngularApp/e2e/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"experimentalDecorators": true,
66
"emitDecoratorMetadata": true,
77
"importHelpers": false,
8+
"sourceMap": true,
89
"types": [
910
"mocha",
1011
"chai",

demo/JavaScriptApp/e2e/config/appium.capabilities.json

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

demo/JavaScriptApp/e2e/tests.e2e-spec.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ describe("sample scenario", function () {
99
driver = await nsAppium.createDriver();
1010
}));
1111

12-
beforeEach(async function () {
13-
try {
14-
const lblPlatform = await getPlatformLabel();
15-
}
16-
catch (err) {
17-
console.log("Navigating to main page ...");
18-
await driver.navBack();
19-
}
20-
});
21-
2212
afterEach(async function () {
2313
if (this.currentTest.state === "failed") {
2414
await driver.logTestArtifacts(this.currentTest.title);
@@ -53,12 +43,10 @@ describe("sample scenario", function () {
5343

5444
it(`should find an element with ${styleType} style applied`, async function () {
5545
const element = await driver.findElementByText(styleTypes[styleType]);
46+
driver.imageHelper.options.keepOriginalImageSize = false;
47+
driver.imageHelper.options.isDeviceSpecific = false;
5648
const result = await driver.compareElement(element, "style");
57-
chai.assert.isTrue(result);
49+
assert.isTrue(result);
5850
});
5951
}
60-
61-
const getPlatformLabel = async function() {
62-
return driver.isAndroid ? await driver.findElementByText("android") : await driver.findElementByText("ios");
63-
}
6452
});

demo/TypeScriptApp/.vscode/launch.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
"--colors",
1818
"--opts",
1919
"./e2e/config/mocha.opts",
20-
"--runType",
21-
"android23",
22-
"--reuseDevice"
23-
// "${workspaceFolder}/test"
20+
"-a"
2421
],
2522
"internalConsoleOptions": "openOnSessionStart"
2623
},

demo/TypeScriptApp/e2e/config/appium.capabilities.json

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

demo/TypeScriptApp/e2e/config/mocha.opts

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

0 commit comments

Comments
 (0)