Skip to content

chore: update appium tests to support ns-dev-appium 6.0.0 #1940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export class AnimationsWithDefaultOptionsPage extends BasePage {
}

private getItem(item) {
return this._driver.findElementByXPathIfExists(`${this._elementHelper.getXPathByTextAtributes("//*", "itemsContainer", true)}${this._elementHelper.getXPathByTextAtributes("//*", item, false)}`);
return this._driver.findElementByXPathIfExists(`${this._elementHelper.getXPathByTextAttributes("//*", "itemsContainer", true)}${this._elementHelper.getXPathByTextAttributes("//*", item, false)}`);
}

async awaitItemToDissapear(item: string, wait: number = 3000) {
async awaitItemToDisappear(item: string, wait: number = 3000) {
const startTime = Date.now();
let btn = await this.getItem(item);
while (btn && await btn.isDisplayed() && Date.now() - startTime <= wait) {
Expand All @@ -53,16 +53,16 @@ export class AnimationsWithDefaultOptionsPage extends BasePage {
}

async getChildren() {
const children: Array<UIElement> = await this._driver.findElementsByXPath(`${this._elementHelper.getXPathByTextAtributes("//*", "itemsContainer", true)}/*`);
const children: Array<UIElement> = await this._driver.findElementsByXPath(`${this._elementHelper.getXPathByTextAttributes("//*", "itemsContainer", true)}/*`);
const orderedList: Array<UIElement> = await sort(children);

return orderedList;
}

async assertItemPosition(text: string, itemIndex: number, expctedElementsCount: number) {
async assertItemPosition(text: string, itemIndex: number, expectedElementsCount: number) {
const children = this._children;

assert.isTrue(children.length === expctedElementsCount, `Expected items count: ${expctedElementsCount} is not as actual: ${children.length}`);
assert.isTrue(children.length === expectedElementsCount, `Expected items count: ${expectedElementsCount} is not as actual: ${children.length}`);
const element = children[itemIndex];
console.log("Element text: ", await element.text());
const currentElementText = await element.text();
Expand Down
6 changes: 3 additions & 3 deletions e2e/animation-examples/e2e/pages/query-stagger-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ export class QueryWithStaggerPage extends BasePage {
}

async getChildren() {
const children: Array<UIElement> = await this._driver.findElementsByXPath(`${this._elementHelper.getXPathByTextAtributes("//*", "container", true)}/*`);
const children: Array<UIElement> = await this._driver.findElementsByXPath(`${this._elementHelper.getXPathByTextAttributes("//*", "container", true)}/*`);
const orderedList: Array<UIElement> = await sort(children);

return orderedList;
}

async assertItemPosition(text: string, itemIndex: number, expctedElementsCount: number) {
async assertItemPosition(text: string, itemIndex: number, expectedElementsCount: number) {
const startTime = Date.now();
let item = await this._driver.findElementByTextIfExists(text)
while ((!item || !(await item.isDisplayed())) && Date.now() - startTime <= 3000) { }
const children = await this.getChildren();
assert.isTrue(children.length === expctedElementsCount);
assert.isTrue(children.length === expectedElementsCount);
const element = children[itemIndex];
const elementText = await element.text();
console.log("Element text: ", elementText);
Expand Down
10 changes: 5 additions & 5 deletions e2e/animation-examples/e2e/pages/selector-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class SelectorPage extends BasePage {

constructor(_driver: AppiumDriver) {
super(_driver);
this._itemsContainerXpath = this._elementHelper.getXPathByTextAtributes("//*", "itemsContainer", true);
this._itemsContainerXpath = this._elementHelper.getXPathByTextAttributes("//*", "itemsContainer", true);
this._itemsContainerChildrenXpath = `${this._itemsContainerXpath}/*`
}

Expand Down Expand Up @@ -41,18 +41,18 @@ export class SelectorPage extends BasePage {
return orderedList;
}

async assertElementPossition(expctedElementsCount: number) {
async assertElementPosition(expectedElementsCount: number) {
const children = await this.getChildren();
assert.isTrue(children.length === expctedElementsCount)
assert.isTrue(children.length === expectedElementsCount)
for (let index = 0; index < children.length - 1; index++) {
const element = children[index];
const el = await (<any>element.driver()).elementByXPathIfExists(this._elementHelper.getXPathByTextAtributes("//*", `Item No.${index}`, true));
const el = await (<any>element.driver()).elementByXPathIfExists(this._elementHelper.getXPathByTextAttributes("//*", `Item No.${index}`, true));
console.log(await el.text());
assert.isTrue(el && el !== null);
}
}

private itemXpath(item) {
return `${this._itemsContainerXpath}${this._elementHelper.getXPathByTextAtributes("//*", item, false)}`;
return `${this._itemsContainerXpath}${this._elementHelper.getXPathByTextAttributes("//*", item, false)}`;
}
}
8 changes: 4 additions & 4 deletions e2e/animation-examples/e2e/smoke.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ describe("smoke-tests", async function () {
await selectorPage.enterExample();
await selectorPage.addItem();
await selectorPage.waitItemToToggleVisibility("Item No.2", true);
await selectorPage.assertElementPossition(4);
await selectorPage.assertElementPosition(4);

await selectorPage.clickOnItem("second");
await selectorPage.waitItemToToggleVisibility("second", false);
await selectorPage.assertElementPossition(3);
await selectorPage.assertElementPosition(3);
});

it("querry with stagger", async function () {
it("query with stagger", async function () {
const queryWithStaggerPage = new QueryWithStaggerPage(driver);
await queryWithStaggerPage.enterExample();
await queryWithStaggerPage.addItem();
Expand Down Expand Up @@ -103,7 +103,7 @@ describe("smoke-tests", async function () {

await animationWithOptionsPage.clickOnItem("Harley Quinn");
examplesCount--;
await animationWithOptionsPage.awaitItemToDissapear("Harley Quinn");
await animationWithOptionsPage.awaitItemToDisappear("Harley Quinn");
await animationWithOptionsPage.assertItemPosition("Wonder Woman", 1, examplesCount);
await animationWithOptionsPage.assertItemPosition("Joker", 2, examplesCount);
await animationWithOptionsPage.assertItemPosition("Aquaman", 3, examplesCount);
Expand Down
2 changes: 1 addition & 1 deletion tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@angular/platform-browser-dynamic": "~8.1.0",
"@angular/router": "~8.1.0",
"nativescript-angular": "../nativescript-angular",
"nativescript-unit-test-runner": "~0.6.3",
"nativescript-unit-test-runner": "0.7.0",
"rxjs": "~6.3.3",
"tns-core-modules": "next",
"zone.js": "^0.9.1"
Expand Down