From 062bda76586ee46ba5ee400337f7a3129bf6fe03 Mon Sep 17 00:00:00 2001 From: vchimev Date: Wed, 6 Dec 2017 13:39:50 +0200 Subject: [PATCH 1/2] test(AngularApp): update demo tests --- demo/AngularApp/e2e/sample.e2e-spec.ts | 47 ----------------- demo/AngularApp/e2e/tests.e2e-spec.ts | 72 ++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 47 deletions(-) delete mode 100644 demo/AngularApp/e2e/sample.e2e-spec.ts create mode 100644 demo/AngularApp/e2e/tests.e2e-spec.ts diff --git a/demo/AngularApp/e2e/sample.e2e-spec.ts b/demo/AngularApp/e2e/sample.e2e-spec.ts deleted file mode 100644 index e3ee67de..00000000 --- a/demo/AngularApp/e2e/sample.e2e-spec.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium"; -import { assert } from "chai"; - -describe("sample scenario", () => { - const defaultWaitTime = 5000; - let driver: AppiumDriver; - - before(async () => { - driver = await createDriver(); - }); - - beforeEach(async function () { }); - - afterEach(async function () { - if (this.currentTest.state === "failed") { - await driver.logScreenshot(this.currentTest.title); - } - }); - - after(async () => { - await driver.quit(); - console.log("Quit driver!"); - }); - - it("should find platform specific items", async () => { - const items = await getItems(); - assert.isTrue(items.length > 1); - }); - - // it("should have CSS applied on items", async () => { - // const screen = await driver.compareScreen("items-component"); - // assert.isTrue(screen); - // }); - - it("should find Ninjas", async () => { - const btnNinjas = await driver.findElementByText("Ninjas"); - await btnNinjas.click(); - const lblNinjas = await driver.findElementByText("Ninjas!"); - }); - - // it("should have CSS applied on Ninjas", async () => { - // const screen = await driver.compareScreen("ninjas-component"); - // assert.isTrue(screen); - // }); - - const getItems = async () => { return driver.isAndroid ? await driver.findElementsByText("(Android)") : await driver.findElementsByText("(ios)"); } -}); diff --git a/demo/AngularApp/e2e/tests.e2e-spec.ts b/demo/AngularApp/e2e/tests.e2e-spec.ts new file mode 100644 index 00000000..1c008f75 --- /dev/null +++ b/demo/AngularApp/e2e/tests.e2e-spec.ts @@ -0,0 +1,72 @@ +import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium"; +import { assert } from "chai"; + +describe("sample scenario", () => { + const defaultWaitTime = 5000; + let driver: AppiumDriver; + + before(async () => { + driver = await createDriver(); + }); + + beforeEach(async function () { + try { + const items = await getItems(); + } catch (err) { + try { + const lblNinjas = await driver.findElementByText("Ninjas!"); + } + catch (err) { + console.log("Navigating to ninjas page ..."); + await driver.navBack(); + } + console.log("Navigating to main page ..."); + await driver.navBack(); + } + }); + + afterEach(async function () { + if (this.currentTest.state === "failed") { + await driver.logPageSource(this.currentTest.title); + await driver.logScreenshot(this.currentTest.title); + } + }); + + after(async () => { + await driver.quit(); + console.log("Quit driver!"); + }); + + it("should navigate to a ninja", async () => { + const btnNinjas = await driver.findElementByText("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]); + const result = await driver.compareElement(element, "style"); + assert.isTrue(result); + }); + } + + const getItems = async () => { return driver.isAndroid ? await driver.findElementsByText("(Android)") : await driver.findElementsByText("(ios)"); } +}); From f86ebf3c422cb5003b75b2064d186f9b884b513a Mon Sep 17 00:00:00 2001 From: vchimev Date: Wed, 6 Dec 2017 14:08:45 +0200 Subject: [PATCH 2/2] refactor: remove unused variable --- demo/AngularApp/e2e/tests.e2e-spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/demo/AngularApp/e2e/tests.e2e-spec.ts b/demo/AngularApp/e2e/tests.e2e-spec.ts index 1c008f75..80a5e51e 100644 --- a/demo/AngularApp/e2e/tests.e2e-spec.ts +++ b/demo/AngularApp/e2e/tests.e2e-spec.ts @@ -2,7 +2,6 @@ import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appi import { assert } from "chai"; describe("sample scenario", () => { - const defaultWaitTime = 5000; let driver: AppiumDriver; before(async () => {