mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
tests: update ns-dev-appium (#7411)
* tests: update ns-dev-appium * chore: package.json
This commit is contained in:
2
e2e/ui-tests-app/.vscode/launch.json
vendored
2
e2e/ui-tests-app/.vscode/launch.json
vendored
@@ -15,7 +15,7 @@
|
||||
"--colors",
|
||||
"--opts",
|
||||
"../config/mocha.opts",
|
||||
"--grep=bottom-navigation",
|
||||
"--grep=tab-view",
|
||||
"-a",
|
||||
|
||||
],
|
||||
|
||||
@@ -1,109 +1,6 @@
|
||||
import { AppiumDriver, logError, IRectangle, UIElement } from "nativescript-dev-appium";
|
||||
import { ImageOptions } from "nativescript-dev-appium/lib/image-options";
|
||||
import { assert } from "chai";
|
||||
|
||||
interface IImageCompareOptions {
|
||||
imageName?: string;
|
||||
timeOutSeconds?: number;
|
||||
tolerance?: number;
|
||||
toleranceType?: ImageOptions;
|
||||
waitOnCreatingInitialSnapshot?: number;
|
||||
}
|
||||
export const setImageName = (suite: string, spec: string, testsName: string) => {
|
||||
const testName = `${suite}-${spec}-${testsName.replace(suite, "").replace(spec, "")}`.replace(/(\-+)/ig, "-").replace(/(\_+)/ig, "_");
|
||||
|
||||
export class ImageHelper {
|
||||
|
||||
private _imagesResults = new Map<string, boolean>();
|
||||
private _testName: string;
|
||||
|
||||
constructor(private _driver: AppiumDriver, private _imageComppareOptions?: IImageCompareOptions) {
|
||||
this._driver.imageHelper.waitOnCreatingInitialSnapshot = (this._imageComppareOptions && this._imageComppareOptions.waitOnCreatingInitialSnapshot) || this.defualtOptions.waitOnCreatingInitialSnapshot;
|
||||
}
|
||||
|
||||
public defualtOptions: IImageCompareOptions = {
|
||||
timeOutSeconds: 2,
|
||||
tolerance: 0,
|
||||
toleranceType: ImageOptions.pixel,
|
||||
waitOnCreatingInitialSnapshot: 2000,
|
||||
};
|
||||
|
||||
get imageComppareOptions() {
|
||||
this.extendOptions(this._imageComppareOptions);
|
||||
|
||||
return this._imageComppareOptions;
|
||||
}
|
||||
|
||||
set imageComppareOptions(imageComppareOptions: IImageCompareOptions) {
|
||||
this._imageComppareOptions = imageComppareOptions;
|
||||
}
|
||||
|
||||
public async compareScreen(options?: IImageCompareOptions) {
|
||||
options = this.extendOptions(options);
|
||||
const imageName = this.increaseImageName(options.imageName || this._testName);
|
||||
const result = await this._driver.compareScreen(imageName, options.timeOutSeconds, options.tolerance, options.toleranceType);
|
||||
this._imagesResults.set(imageName, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async compareElement(element: UIElement, options?: IImageCompareOptions) {
|
||||
options = this.extendOptions(options);
|
||||
const imageName = this.increaseImageName(options.imageName || this._testName);
|
||||
const result = await this._driver.compareElement(element, imageName, options.tolerance, options.timeOutSeconds, options.toleranceType);
|
||||
this._imagesResults.set(imageName, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async compareRectangle(element: IRectangle, options?: IImageCompareOptions) {
|
||||
options = this.extendOptions(options);
|
||||
const imageName = this.increaseImageName(options.imageName || this._testName);
|
||||
const result = await this._driver.compareRectangle(element, imageName, options.timeOutSeconds, options.tolerance, options.toleranceType);
|
||||
this._imagesResults.set(imageName, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public assertImages() {
|
||||
let shouldFailTest = false;
|
||||
console.log();
|
||||
this._imagesResults.forEach((v, k, map) => {
|
||||
if (!this._imagesResults.get(k)) {
|
||||
shouldFailTest = true;
|
||||
logError(`Image comparisson for image ${k} failed`);
|
||||
}
|
||||
});
|
||||
|
||||
this.reset();
|
||||
assert.isTrue(!shouldFailTest, `Image comparisson failers`);
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this._imagesResults.clear();
|
||||
}
|
||||
|
||||
public setImageName(suite: string, spec: string, testsName: string) {
|
||||
this._testName = `${suite}-${spec}-${testsName.replace(suite, "").replace(spec, "")}`.replace(/(\-+)/ig, "-").replace(/(\_+)/ig, "_");
|
||||
|
||||
return this._testName;
|
||||
}
|
||||
|
||||
private increaseImageName(imageName: string) {
|
||||
if (this._imagesResults.size > 1) {
|
||||
const number = /\d+$/.test(imageName) ? +`${/\d+$/.exec(imageName)}` + 1 : `2`;
|
||||
imageName = `${imageName}_${number}`;
|
||||
}
|
||||
|
||||
return imageName;
|
||||
}
|
||||
|
||||
private extendOptions(options: IImageCompareOptions) {
|
||||
options = options || {};
|
||||
Object.getOwnPropertyNames(this.defualtOptions).forEach(prop => {
|
||||
if (!options[prop]) {
|
||||
options[prop] = this.defualtOptions[prop];
|
||||
}
|
||||
});
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
return testName;
|
||||
};
|
||||
@@ -93,7 +93,10 @@ export class NavigationHelper {
|
||||
|
||||
async navigateBackToSuitMainPage() {
|
||||
logInfo(`Navigate to back`);
|
||||
this._currentSuite = this._currentSuite.parent;
|
||||
if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce
|
||||
|| this._elemtsCacheStrategy === ElementCacheStrategy.onload) {
|
||||
this._currentSuite = this._currentSuite && this._currentSuite.parent;
|
||||
}
|
||||
await this._driver.navBack();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import { AppiumDriver, logInfo } from "nativescript-dev-appium";
|
||||
import { NavigationHelper, ElementCacheStrategy } from "./helpers/navigation-helper";
|
||||
import { ImageHelper } from "./helpers/image-helper";
|
||||
|
||||
export abstract class PageObjectBaseModel {
|
||||
|
||||
public navigationHelper: NavigationHelper;
|
||||
public imageHelper: ImageHelper;
|
||||
|
||||
constructor(protected _driver: AppiumDriver, protected _naviagtionLinks: Array<string>, elementCacheStrategy: ElementCacheStrategy = ElementCacheStrategy.none) {
|
||||
this.navigationHelper = new NavigationHelper(this._driver, this._naviagtionLinks, elementCacheStrategy);
|
||||
this.imageHelper = new ImageHelper(this._driver);
|
||||
}
|
||||
|
||||
async initSuite() {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { AppiumDriver, logInfo, logError } from "nativescript-dev-appium";
|
||||
import { Platform } from "mobile-devices-controller";
|
||||
import { ImageOptions } from "nativescript-dev-appium/lib/image-options";
|
||||
import { PageObjectBaseModel } from "../../../page-object-base-model";
|
||||
import { ElementCacheStrategy } from "../../../helpers/navigation-helper";
|
||||
|
||||
import { assert } from "chai";
|
||||
export class ButtonBackgroundPage extends PageObjectBaseModel {
|
||||
|
||||
constructor(_driver: AppiumDriver) {
|
||||
@@ -47,7 +46,7 @@ export class ButtonBackgroundPage extends PageObjectBaseModel {
|
||||
async executeScenario(imageName: string, button: string) {
|
||||
const presenter = await this.testElement();
|
||||
await this.tapBtn(button);
|
||||
await this.imageHelper.compareElement(presenter, { imageName: imageName, tolerance: 0.1, timeOutSeconds: 5 });
|
||||
this.imageHelper.assertImages();
|
||||
await this._driver.imageHelper.compareElement(presenter, { imageName: imageName, tolerance: 0.1, timeOutSeconds: 5 });
|
||||
assert.isTrue(this._driver.imageHelper.hasImageComparisonPassed());
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
|
||||
import { ButtonBackgroundPage } from "./button-background-page";
|
||||
import { assert } from "chai";
|
||||
|
||||
const suite = "tab-navigation";
|
||||
const spec = "bottom-navigation";
|
||||
const suite = "button";
|
||||
const spec = "background";
|
||||
|
||||
describe(`${suite}-${spec}-suite`, () => {
|
||||
let driver: AppiumDriver;
|
||||
@@ -21,19 +22,21 @@ describe(`${suite}-${spec}-suite`, () => {
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
backgroundPage.imageHelper.setImageName(suite, spec, this.currentTest.title);
|
||||
driver.imageHelper.testName = this.currentTest.title;
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
if (this.currentTest.state === "failed") {
|
||||
await driver.logTestArtifacts(this.currentTest.title);
|
||||
await driver.resetApp();
|
||||
await backgroundPage.initSuite();
|
||||
}
|
||||
});
|
||||
|
||||
it("background_11", async function () {
|
||||
const presenter = await backgroundPage.testElement();
|
||||
await backgroundPage.imageHelper.compareElement(presenter, { imageName: "background_11_clean", tolerance: 0.1 });
|
||||
backgroundPage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareElement(presenter, { imageName: "background_11_clean", tolerance: 0.1 });
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
});
|
||||
|
||||
it("background_12", async function () {
|
||||
@@ -43,8 +46,8 @@ describe(`${suite}-${spec}-suite`, () => {
|
||||
it("background_13", async function () {
|
||||
await backgroundPage.tapResetBtn();
|
||||
const presenter = await backgroundPage.testElement();
|
||||
await backgroundPage.imageHelper.compareElement(presenter, { imageName: "background_11_clean", tolerance: 0.1 });
|
||||
backgroundPage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareElement(presenter, { imageName: "background_11_clean", tolerance: 0.1 });
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
});
|
||||
|
||||
// Border
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { nsCapabilities, createDriver, AppiumDriver } from "nativescript-dev-appium";
|
||||
import { BottomNavigationBasePage } from "./bottom-navigation-base-page";
|
||||
import { Platform } from "mobile-devices-controller";
|
||||
import { assert } from "chai";
|
||||
import { setImageName } from "../../../helpers/image-helper";
|
||||
|
||||
const suite = "tab-navigation";
|
||||
const spec = "bottom-navigation";
|
||||
|
||||
describe(`${suite}-${spec}-tests-suite`, async function () {
|
||||
describe(`${suite}-${spec}-suite`, async function () {
|
||||
let driver: AppiumDriver;
|
||||
let bottomNavigationBasePage: BottomNavigationBasePage;
|
||||
|
||||
@@ -22,10 +24,11 @@ describe(`${suite}-${spec}-tests-suite`, async function () {
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
bottomNavigationBasePage.imageHelper.setImageName(suite, spec, this.currentTest.title);
|
||||
bottomNavigationBasePage.imageHelper.defualtOptions = {
|
||||
driver.imageHelper.testName = setImageName(suite, spec, this.currentTest.title);
|
||||
driver.imageHelper.options = {
|
||||
tolerance: 0.01,
|
||||
timeOutSeconds: 5
|
||||
timeOutSeconds: 5,
|
||||
preserveImageName: true
|
||||
};
|
||||
});
|
||||
|
||||
@@ -40,23 +43,23 @@ describe(`${suite}-${spec}-tests-suite`, async function () {
|
||||
it(`${spec}-background-color`, async function () {
|
||||
await bottomNavigationBasePage.navigateToSample("background-color");
|
||||
|
||||
await bottomNavigationBasePage.imageHelper.compareScreen();
|
||||
await bottomNavigationBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
|
||||
await bottomNavigationBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-bottom-navigation`, async function () {
|
||||
await bottomNavigationBasePage.navigateToSample("bottom-navigation");
|
||||
await bottomNavigationBasePage.imageHelper.compareScreen();
|
||||
await bottomNavigationBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await bottomNavigationBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-color`, async function () {
|
||||
await bottomNavigationBasePage.navigateToSample("color");
|
||||
await bottomNavigationBasePage.imageHelper.compareScreen();
|
||||
await bottomNavigationBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await bottomNavigationBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
@@ -67,42 +70,42 @@ describe(`${suite}-${spec}-tests-suite`, async function () {
|
||||
|
||||
let btns = await driver.findElementsByClassName(driver.locators.button, 5000);
|
||||
await btns[index].tap();
|
||||
await bottomNavigationBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
btns = await driver.findElementsByClassName(driver.locators.button, 5000);
|
||||
await btns[index - 1].tap();
|
||||
await bottomNavigationBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
await bottomNavigationBasePage.imageHelper.assertImages();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
|
||||
await bottomNavigationBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-icon-title-placment`, async function () {
|
||||
await bottomNavigationBasePage.navigateToSample("icon-title-placement");
|
||||
await bottomNavigationBasePage.imageHelper.compareScreen();
|
||||
await bottomNavigationBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await bottomNavigationBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-issue-5470`, async function () {
|
||||
await bottomNavigationBasePage.navigateToSample("issue-5470");
|
||||
await bottomNavigationBasePage.imageHelper.compareScreen();
|
||||
await bottomNavigationBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await bottomNavigationBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-swipe-enabled`, async function () {
|
||||
await bottomNavigationBasePage.navigateToSample("swipe-enabled");
|
||||
await bottomNavigationBasePage.imageHelper.compareScreen();
|
||||
await bottomNavigationBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await bottomNavigationBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-tab-position`, async function () {
|
||||
await bottomNavigationBasePage.navigateToSample("tab-position");
|
||||
await bottomNavigationBasePage.imageHelper.compareScreen();
|
||||
await bottomNavigationBasePage.imageHelper.assertImages();
|
||||
it(`${spec}-tabs-position`, async function () {
|
||||
await bottomNavigationBasePage.navigateToSample("tabs-position");
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await bottomNavigationBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
});
|
||||
@@ -1,11 +1,13 @@
|
||||
import { nsCapabilities, createDriver, AppiumDriver } from "nativescript-dev-appium";
|
||||
import { TabViewBasePage } from "./tab-view-base-page";
|
||||
import { Platform } from "mobile-devices-controller";
|
||||
import { setImageName } from "../../../helpers/image-helper";
|
||||
import { assert } from "chai";
|
||||
|
||||
const suite = "tabs";
|
||||
const spec = "tab-view";
|
||||
const suite = "tab-navigation";
|
||||
const spec = "tab-view-common";
|
||||
|
||||
describe(`${suite}-${spec}-common-tests-suite`, async function () {
|
||||
describe(`${suite}-${spec}-suite`, async function () {
|
||||
let driver: AppiumDriver;
|
||||
let tabViewBasePage: TabViewBasePage;
|
||||
|
||||
@@ -22,8 +24,8 @@ describe(`${suite}-${spec}-common-tests-suite`, async function () {
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
tabViewBasePage.imageHelper.setImageName(suite, spec, this.currentTest.title);
|
||||
tabViewBasePage.imageHelper.defualtOptions = {
|
||||
driver.imageHelper.testName = setImageName(suite, spec, this.currentTest.title);
|
||||
driver.imageHelper.options = {
|
||||
tolerance: 0.01,
|
||||
timeOutSeconds: 5
|
||||
};
|
||||
@@ -40,8 +42,8 @@ describe(`${suite}-${spec}-common-tests-suite`, async function () {
|
||||
it(`${spec}-style`, async function () {
|
||||
await tabViewBasePage.navigateToSample("tabStyle");
|
||||
|
||||
await tabViewBasePage.imageHelper.compareScreen({ timeOutSeconds: 5, tolerance: 0.01 });
|
||||
await tabViewBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen({ timeOutSeconds: 5, tolerance: 0.01 });
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
|
||||
await tabViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
@@ -49,42 +51,42 @@ describe(`${suite}-${spec}-common-tests-suite`, async function () {
|
||||
it(`${spec}-more-items`, async function () {
|
||||
await tabViewBasePage.navigateToSample("tabmore");
|
||||
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await tabViewBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
|
||||
await tabViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-icons`, async function () {
|
||||
await tabViewBasePage.navigateToSample("tab-view-icons");
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
const rect = await (await driver.waitForElement("automatic")).getActualRectangle();
|
||||
|
||||
await driver.clickPoint(rect.x + 10, rect.y + 10);
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
await driver.clickPoint(rect.x + 10, rect.y + 10);
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
await driver.clickPoint(rect.x + 10, rect.y + 10);
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
await tabViewBasePage.imageHelper.assertImages();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
|
||||
await tabViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-fonts`, async function () {
|
||||
await tabViewBasePage.navigateToSample("text-transform");
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
await (await driver.waitForElement("apply")).tap();
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
await (await driver.waitForElement("reset")).tap();
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await tabViewBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
|
||||
await tabViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
@@ -96,13 +98,13 @@ describe(`${suite}-${spec}-common-tests-suite`, async function () {
|
||||
|
||||
let btns = await driver.findElementsByClassName(driver.locators.button, 5000);
|
||||
await btns[index].tap();
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
btns = await driver.findElementsByClassName(driver.locators.button, 5000);
|
||||
await btns[index - 1].tap();
|
||||
await tabViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
await tabViewBasePage.imageHelper.assertImages();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
|
||||
await tabViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
@@ -3,11 +3,13 @@ import { TabViewBasePage } from "./tab-view-base-page";
|
||||
import { ImageOptions } from "nativescript-dev-appium/lib/image-options";
|
||||
import { Platform } from "mobile-devices-controller";
|
||||
import { ElementCacheStrategy } from "../../../helpers/navigation-helper";
|
||||
import { setImageName } from "../../../helpers/image-helper";
|
||||
import { assert } from "chai";
|
||||
|
||||
const suite = "tabs";
|
||||
const spec = "tab-view";
|
||||
const suite = "tab-navigation";
|
||||
const spec = "tab-view-css";
|
||||
|
||||
describe(`${suite}-${spec}-css-suite`, async function () {
|
||||
describe(`${suite}-${spec}-suite`, async function () {
|
||||
let driver: AppiumDriver;
|
||||
let tabViewBasePage: TabViewBasePage;
|
||||
|
||||
@@ -35,7 +37,7 @@ describe(`${suite}-${spec}-css-suite`, async function () {
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
tabViewBasePage.imageHelper.setImageName(suite, spec, this.currentTest.title);
|
||||
driver.imageHelper.testName = setImageName(suite, spec, this.currentTest.title);
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
@@ -57,14 +59,14 @@ describe(`${suite}-${spec}-css-suite`, async function () {
|
||||
const scenarioBtn = await driver.waitForElement(sample);
|
||||
await scenarioBtn.click();
|
||||
await driver.wait(2000);
|
||||
await tabViewBasePage.imageHelper.compareScreen({ imageName: imageName, timeOutSeconds: 5, tolerance: 0, toleranceType: ImageOptions.pixel });
|
||||
await driver.imageHelper.compareScreen({ imageName: imageName, timeOutSeconds: 5, tolerance: 0, toleranceType: ImageOptions.pixel });
|
||||
if (sample === "All") {
|
||||
const tabTwo = await driver.waitForElement("twO");
|
||||
await driver.wait(2000);
|
||||
|
||||
await tabViewBasePage.imageHelper.compareElement(tabTwo, { timeOutSeconds: 5, tolerance: 0, toleranceType: ImageOptions.pixel });
|
||||
await driver.imageHelper.compareElement(tabTwo, { timeOutSeconds: 5, tolerance: 0, toleranceType: ImageOptions.pixel });
|
||||
}
|
||||
tabViewBasePage.imageHelper.assertImages();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,11 +1,13 @@
|
||||
import { nsCapabilities, createDriver, AppiumDriver } from "nativescript-dev-appium";
|
||||
import { TabsViewBasePage } from "./tabs-view-base-page";
|
||||
import { Platform } from "mobile-devices-controller";
|
||||
import { assert } from "chai";
|
||||
import { setImageName } from "../../../helpers/image-helper";
|
||||
|
||||
const suite = "tabs";
|
||||
const suite = "tab-navigation";
|
||||
const spec = "tabs";
|
||||
|
||||
describe(`${suite}-${spec}-tests-suite`, async function () {
|
||||
describe(`${suite}-${spec}-suite`, async function () {
|
||||
let driver: AppiumDriver;
|
||||
let tabsViewBasePage: TabsViewBasePage;
|
||||
|
||||
@@ -22,11 +24,11 @@ describe(`${suite}-${spec}-tests-suite`, async function () {
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
tabsViewBasePage.imageHelper.setImageName(suite, spec, this.currentTest.title);
|
||||
tabsViewBasePage.imageHelper.defualtOptions = {
|
||||
imageName: this.currentTest.title,
|
||||
driver.imageHelper.testName = setImageName(suite, spec, this.currentTest.title);
|
||||
driver.imageHelper.options = {
|
||||
tolerance: 0.01,
|
||||
timeOutSeconds: 5
|
||||
timeOutSeconds: 5,
|
||||
preserveImageName: true
|
||||
};
|
||||
});
|
||||
|
||||
@@ -41,23 +43,23 @@ describe(`${suite}-${spec}-tests-suite`, async function () {
|
||||
it(`${spec}-background-color`, async function () {
|
||||
await tabsViewBasePage.navigateToSample("background-color");
|
||||
|
||||
await tabsViewBasePage.imageHelper.compareScreen();
|
||||
await tabsViewBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
|
||||
await tabsViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-bottom-navigation`, async function () {
|
||||
await tabsViewBasePage.navigateToSample("bottom-navigation");
|
||||
await tabsViewBasePage.imageHelper.compareScreen();
|
||||
await tabsViewBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await tabsViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-color`, async function () {
|
||||
await tabsViewBasePage.navigateToSample("color");
|
||||
await tabsViewBasePage.imageHelper.compareScreen();
|
||||
await tabsViewBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await tabsViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
@@ -68,42 +70,42 @@ describe(`${suite}-${spec}-tests-suite`, async function () {
|
||||
|
||||
let btns = await driver.findElementsByClassName(driver.locators.button, 5000);
|
||||
await btns[index].tap();
|
||||
await tabsViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
btns = await driver.findElementsByClassName(driver.locators.button, 5000);
|
||||
await btns[index - 1].tap();
|
||||
await tabsViewBasePage.imageHelper.compareScreen();
|
||||
await driver.imageHelper.compareScreen();
|
||||
|
||||
await tabsViewBasePage.imageHelper.assertImages();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
|
||||
await tabsViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-icon-title-placment`, async function () {
|
||||
await tabsViewBasePage.navigateToSample("icon-title-placement");
|
||||
await tabsViewBasePage.imageHelper.compareScreen();
|
||||
await tabsViewBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await tabsViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-issue-5470`, async function () {
|
||||
await tabsViewBasePage.navigateToSample("issue-5470");
|
||||
await tabsViewBasePage.imageHelper.compareScreen();
|
||||
await tabsViewBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await tabsViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-swipe-enabled`, async function () {
|
||||
await tabsViewBasePage.navigateToSample("swipe-enabled");
|
||||
await tabsViewBasePage.imageHelper.compareScreen();
|
||||
await tabsViewBasePage.imageHelper.assertImages();
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await tabsViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
|
||||
it(`${spec}-tab-position`, async function () {
|
||||
await tabsViewBasePage.navigateToSample("tab-position");
|
||||
await tabsViewBasePage.imageHelper.compareScreen();
|
||||
await tabsViewBasePage.imageHelper.assertImages();
|
||||
it(`${spec}-tabs-position`, async function () {
|
||||
await tabsViewBasePage.navigateToSample("tabs-position");
|
||||
await driver.imageHelper.compareScreen();
|
||||
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
|
||||
await tabsViewBasePage.navigateBackToSuitMainPage();
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@
|
||||
"nativescript": {
|
||||
"id": "org.nativescript.uitestsapp",
|
||||
"tns-android": {
|
||||
"version": "6.0.0-2019-06-24-113546-01"
|
||||
"version": "next"
|
||||
},
|
||||
"tns-ios": {
|
||||
"version": "next"
|
||||
|
||||
Reference in New Issue
Block a user