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
test(AngularApp): update demo tests #333
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)"); } | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope