-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathscreen.ts
327 lines (266 loc) · 11.5 KB
/
screen.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
import { AppiumDriver, SearchOptions } from "nativescript-dev-appium";
import { assert } from "chai";
const home = "Home Component"
const first = "First"
const modal = "Modal";
const modalFirst = "Modal First";
const dialogConfirm = "Dialog";
const modalSecond = "Modal Second";
const modalNested = "Modal Nested";
const modalFrame = "Show Modal Page With Frame";
const modalNoFrame = "Show Modal Without Frame";
const modalLayout = "Show Modal Layout";
const modalTabView = "Show Modal TabView";
const navToSecondPage = "Navigate To Second Page";
const showDialog = "Show Dialog";
const resetFrameRootView = "Reset Frame Root View";
const resetFrameRootViewModal = "Reset Frame Root View Modal";
const resetNamedFrameRootView = "Reset Named Frame Root View";
const resetNamedFrameRootViewModal = "Reset Named Frame Root View Modal";
const resetTabRootView = "Reset Tab Root View";
const resetTabRootViewModal = "Reset Tab Root View Modal";
const resetLayoutRootView = "Reset Layout Root View";
const resetLayoutRootViewModal = "Reset Layout Root View Modal";
const showNestedModalFrame = "Show Nested Modal Page With Frame";
const showNestedModalPage = "Show Nested Modal Page";
const confirmDialog = "Yes";
const confirmDialogMessage = "Message";
const closeModalNested = "Close Modal Nested";
const closeModal = "Close Modal";
const goBack = "Go Back(activatedRoute)";
export const sharedModalView = "SHARED MODAL VIEW";
export const homeComponent = "Home Component";
export class Screen {
private _driver: AppiumDriver
constructor(driver: AppiumDriver) {
this._driver = driver;
}
loadedHome = async () => {
const lblHome = await this._driver.waitForElement(home);
assert.isTrue(await lblHome.isDisplayed());
console.log(home + " loaded!");
}
resetFrameRootView = async () => {
console.log("Setting frame root ...");
const btnResetFrameRootView = await this._driver.findElementByAutomationText(resetFrameRootView);
await btnResetFrameRootView.tap();
}
resetNamedFrameRootView = async () => {
console.log("Setting named frame root ...");
const btnResetFrameRootView = await this._driver.findElementByAutomationText(resetNamedFrameRootView);
await btnResetFrameRootView.tap();
}
resetLayoutRootView = async () => {
console.log("Setting layout root ...");
const btnResetLayoutRootView = await this._driver.waitForElement(resetLayoutRootView);
await btnResetLayoutRootView.click();
}
resetTabRootView = async () => {
const btnResetTabRootView = await this._driver.findElementByAutomationText(resetTabRootView);
await btnResetTabRootView.tap();
}
resetTabRootViewModal = async () => {
const btnResetTabRootViewModal = await this._driver.findElementByAutomationText(resetTabRootViewModal);
await btnResetTabRootViewModal.click();
}
resetFrameRootViewModal = async () => {
const btnResetTabRootViewModal = await this._driver.findElementByAutomationText(resetFrameRootViewModal);
await btnResetTabRootViewModal.click();
}
resetNamedFrameRootViewModal = async () => {
const btnResetTabRootViewModal = await this._driver.findElementByAutomationText(resetNamedFrameRootViewModal);
await btnResetTabRootViewModal.click();
}
resetLayoutRootViewModal = async () => {
const btnResetTabRootViewModal = await this._driver.findElementByAutomationText(resetLayoutRootViewModal);
await btnResetTabRootViewModal.click();
}
loadedTabRootView = async () => {
const tabFirst = await this._driver.findElementByAutomationText(first);
assert.isTrue(await tabFirst.isDisplayed());
console.log("Tab root view loaded!");
}
setFrameRootView = async () => {
// should load frame root, no need to verify it is loaded
await this.loadedHome();
await this.resetFrameRootView();
}
setNamedFrameRootView = async () => {
// should load named frame root, no need to verify it is loaded
await this.loadedHome();
await this.resetNamedFrameRootView();
}
setTabRootView = async () => {
// should load tab root
await this.loadedHome();
await this.resetTabRootView();
await this.loadedTabRootView();
}
setLayoutRootView = async () => {
// should load layout root, no need to verify it is loaded
await this.loadedHome();
await this.resetLayoutRootView();
}
setTabRootViewModal = async () => {
await this.loadedHome();
await this.resetTabRootViewModal();
}
setFrameRootViewModal = async () => {
await this.loadedHome();
await this.resetFrameRootViewModal();
}
setNamedFrameRootViewModal = async () => {
await this.loadedHome();
await this.resetNamedFrameRootViewModal();
}
setLayoutRootViewModal = async () => {
await this.loadedHome();
await this.resetLayoutRootViewModal();
}
showModalFrame = async () => {
const btnModalFrame = await this._driver.findElementByAutomationText(modalFrame);
await btnModalFrame.tap();
}
loadedModalFrame = async () => {
const lblModal = await this._driver.waitForElement(modal, 5000);
assert.isTrue(await lblModal.isDisplayed(), `${modal} is not displayed!`);
console.log(modal + " loaded!");
}
showModalNoFrame = async () => {
const btnModalPage = await this._driver.findElementByAutomationText(modalNoFrame);
await btnModalPage.tap();
}
private showSharedModal = async () => {
const btnTap = await this._driver.waitForElement("Show Shared Modal");
await btnTap.click();
}
private showSharedModalPresentationStyle = async () => {
const btnTap = await this._driver.findElementByText("popover", SearchOptions.contains);
await btnTap.click();
}
loadedModalPage = async () => {
const btnShowNestedModalPage = await this._driver.findElementByAutomationText(showNestedModalPage);
assert.isTrue(await btnShowNestedModalPage.isDisplayed(), `${showNestedModalPage} is not displayed`);
console.log("Modal Page loaded!");
}
showModalLayout = async () => {
const btnModalLayout = await this._driver.findElementByAutomationText(modalLayout);
await btnModalLayout.tap();
}
loadedModalLayout = async () => {
await this.loadedModalFrame();
}
showModalTabView = async () => {
const btnModalTabView = await this._driver.findElementByAutomationText(modalTabView);
await btnModalTabView.tap();
}
loadedModalTabView = async () => {
const itemModalFirst = await this._driver.findElementByAutomationText(modalFirst);
assert.isTrue(await itemModalFirst.isDisplayed());
console.log("Modal TabView loaded!");
}
navigateToSecondPage = async () => {
const btnNavToSecondPage = await this._driver.findElementByAutomationText(navToSecondPage);
await btnNavToSecondPage.tap();
}
showDialogConfirm = async () => {
const btnShowDialogConfirm = await this._driver.findElementByAutomationText(showDialog);
await btnShowDialogConfirm.tap();
}
navigateToFirstItem = async () => {
const itemModalFirst = await this._driver.findElementByAutomationText(modalFirst);
await itemModalFirst.tap();
}
navigateToSecondItem = async () => {
const itemModalSecond = await this._driver.findElementByAutomationText(modalSecond);
await itemModalSecond.tap();
}
loadedModalNoFrame = async () => {
await this._driver.wait(2000);
const btnShowDialogConfirm = await this._driver.waitForElement(showDialog);
const btnCloseModal = await this._driver.waitForElement(closeModal);
assert.isTrue(await btnShowDialogConfirm.isDisplayed());
assert.isTrue(await btnCloseModal.isDisplayed());
console.log("Modal Without Frame shown!");
}
loadedConfirmDialog = async () => {
const lblDialogMessage = await this._driver.findElementByAutomationText(confirmDialogMessage);
assert.isTrue(await lblDialogMessage.isDisplayed());
console.log(dialogConfirm + " shown!");
}
loadedSecondPage = async () => {
const lblModalSecond = await this._driver.waitForElement(modalSecond, 5000);
assert.isTrue(await lblModalSecond.isDisplayed());
console.log(modalSecond + " loaded!");
}
loadedFirstItem = async () => {
const lblModal = await this._driver.findElementByAutomationText(modal);
assert.isTrue(await lblModal.isDisplayed());
console.log("First Item loaded!");
}
loadedSecondItem = async () => {
const btnGoBack = await this._driver.findElementByAutomationText(goBack);
assert.isTrue(await btnGoBack.isDisplayed());
console.log("Second Item loaded!");
}
closeDialog = async () => {
const btnYesDialog = await this._driver.findElementByAutomationText(confirmDialog);
await btnYesDialog.tap();
}
goBackFromSecondPage = async () => {
const btnGoBackFromSecondPage = await this._driver.findElementByAutomationText(goBack);
await btnGoBackFromSecondPage.tap();
}
showNestedModalFrame = async () => {
const btnShowNestedModalFrame = await this._driver.findElementByAutomationText(showNestedModalFrame);
await btnShowNestedModalFrame.tap();
}
loadedNestedModalFrame = async () => {
const lblModalNested = await this._driver.waitForElement(modalNested, 5000);
assert.isTrue(await lblModalNested.isDisplayed());
console.log(modalNested + " loaded!");
}
closeModalNested = async () => {
const btnCloseNestedModal = await this._driver.findElementByAutomationText(closeModalNested);
await btnCloseNestedModal.tap();
}
showNestedModalPage = async () => {
const btnShowNestedModalPage = await this._driver.findElementByAutomationText(showNestedModalPage);
await btnShowNestedModalPage.tap();
}
loadedNestedModalPage = async () => {
const btnCloseModalNested = await this._driver.findElementByAutomationText(closeModalNested);
assert.isTrue(await btnCloseModalNested.isDisplayed(), `${closeModalNested} is not shown`);
console.log(closeModalNested + " loaded!");
}
closeModal = async () => {
const btnCloseModal = await this._driver.waitForElement(closeModal, 10000);
await btnCloseModal.click();
}
loadModalNoFrame = async (loadShowModalPageWithFrame: boolean) => {
if (loadShowModalPageWithFrame) {
await this.showModalNoFrame();
}
await this.loadedModalNoFrame();
}
loadModalFrame = async (loadShowModalPageWithFrame: boolean) => {
if (loadShowModalPageWithFrame) {
await this.showModalFrame();
}
await this.loadedModalFrame();
}
loadSharedModal = async (loadShowModalPageWithFrame: boolean) => {
if (loadShowModalPageWithFrame) {
await this.showSharedModal();
}
const lbl = await this._driver.waitForElement(sharedModalView, 5000);
assert.isTrue(await lbl.isDisplayed());
}
loadSharedModalWithPresentationStyle = async (loadShowModalPageWithFrame: boolean) => {
if (loadShowModalPageWithFrame) {
await this.showSharedModalPresentationStyle();
}
const lbl = await this._driver.waitForElement(sharedModalView, 5000);
assert.isTrue(await lbl.isDisplayed());
}
}