Skip to content

Commit bf44253

Browse files
Dimitar TodorovDimitar Todorov
authored andcommitted
Add initial e2e tests in demo-angular
1 parent eccc63f commit bf44253

File tree

13 files changed

+83
-90
lines changed

13 files changed

+83
-90
lines changed

demo-angular/demo.zip

37.6 MB
Binary file not shown.

demo-angular/e2e/config/appium.capabilities.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
"android24": {
3636
"platformName": "Android",
3737
"platformVersion": "7.0",
38-
"deviceName": "Android_GoogleAPI_Emulator",
39-
"avd": "Android_GoogleAPI_Emulator",
38+
"deviceName": "Android GoogleAPI Emulator",
4039
"lt": 60000,
4140
"newCommandTimeout": 720,
42-
"noReset": false,
41+
"appium-version": "1.9.1",
42+
"noReset": true,
4343
"fullReset": false,
44-
"app": ""
44+
"app": "",
45+
"idleTimeout": 120,
46+
"automationName": "Appium"
4547
},
4648
"android25": {
4749
"platformName": "Android",
@@ -107,9 +109,14 @@
107109
"platformName": "iOS",
108110
"platformVersion": "/12*/",
109111
"deviceName": "iPhone X",
110-
"noReset": false,
112+
"appium-version": "1.9.1",
113+
"app": "/Users/dtodorov/SSD/nativescript-datetimepicker/demo-angular/platforms/ios/build/Debug-iphonesimulator/demoangular.app",
114+
"noReset": true,
111115
"fullReset": false,
112-
"app": ""
116+
"density": 3,
117+
"offsetPixels": 87,
118+
"idleTimeout": 120,
119+
"automationName": "Appium"
113120
},
114121
"sim.iPhoneXS": {
115122
"platformName": "ios",

demo-angular/e2e/helper.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { AppiumDriver, SearchOptions, Direction, UIElement } from "nativescript-dev-appium";
1+
import { AppiumDriver, SearchOptions,createDriver, Direction, UIElement } from "nativescript-dev-appium";
22
import { runType } from "nativescript-dev-appium/lib/parser";
33

44
const isAndroid: boolean = runType.includes("android");
55
const optionsText = "Options";
66
const moreOptionsID = "More options";
77

8-
98
export function getDateString() {
109
const date = new Date();
1110
let year = date.getFullYear().toString();
@@ -18,13 +17,32 @@ export function getDateString() {
1817
return dateString;
1918
}
2019

21-
export function getTimeString() {
22-
const date = new Date();
23-
let timeString = date.toLocaleString("en-US", {
24-
hour: "numeric",
25-
minute: "numeric",
26-
hour12: true
27-
});
28-
20+
export async function getPickerTime() {
21+
let driver: AppiumDriver;
22+
driver = await createDriver();
23+
driver.defaultWaitTime = 15000;
24+
let selector = isAndroid ? "android.widget.EditText" : "XCUIElementTypePickerWheel";
25+
const pickerWheels = await driver.findElementsByClassName(selector);
26+
let hourWheel = await (await pickerWheels[0]).text();
27+
let minutesWheel = await (await pickerWheels[1]).text();
28+
const amPmWheel = await (await pickerWheels[2]).text();
29+
if(!isAndroid){
30+
hourWheel = hourWheel.slice(0, hourWheel.indexOf(" "));
31+
minutesWheel = minutesWheel.slice(0, minutesWheel.indexOf(" "));
32+
}
33+
const timeString = hourWheel + ":" + minutesWheel + " " + amPmWheel;
34+
return timeString;
35+
}
36+
37+
export async function getPickerDate() {
38+
let driver: AppiumDriver;
39+
driver = await createDriver();
40+
driver.defaultWaitTime = 15000;
41+
let selector = isAndroid ? "android.widget.EditText" : "XCUIElementTypePickerWheel";
42+
const pickerWheels = await driver.findElementsByClassName(selector);
43+
let monthWheel = await (await pickerWheels[0]).text();
44+
let dayWheel = await (await pickerWheels[1]).text();
45+
const yearWheel = await (await pickerWheels[2]).text();
46+
const timeString = monthWheel + ":" + dayWheel + " " + yearWheel;
2947
return timeString;
3048
}
69.5 KB
Loading
-1.5 KB
Loading
324 KB
Loading
Loading
Loading

demo-angular/e2e/tests.e2e.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appi
22
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
33
import { expect } from "chai";
44
import { ok } from "assert";
5-
import { getDateString, getTimeString } from "./helper";
5+
import { getDateString, getPickerTime } from "./helper";
66
const fs = require('fs');
77
const addContext = require('mochawesome/addContext');
88
const rimraf = require('rimraf');
@@ -65,12 +65,17 @@ describe("DateTimePicker", () => {
6565
it("Should select time and verify value of picker field", async () => {
6666
const selectTimeField = await driver.findElementByText("select time", SearchOptions.contains);
6767
await selectTimeField.click();
68+
const timeString = await getPickerTime();
69+
6870
const okBtn = await driver.findElementByText("OK", SearchOptions.exact);
6971
await okBtn.click();
70-
const timeString = getTimeString();
71-
console.log(timeString);
72-
const timeSelected = await driver.findElementByText(timeString);
72+
const timeSelected = await driver.findElementByText(timeString, SearchOptions.contains);
7373
expect(timeSelected).to.exist;
74-
})
74+
});
75+
76+
it("Should select date from min/max limited field", async () => {
77+
const minMaxLabel = await driver.findElementByText("min and max date", SearchOptions.contains);
78+
79+
});
7580

7681
});

demo-angular/mochawesome-report/mochawesome.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)