Newer
Older
import { element, by, ElementFinder } from 'protractor';
/* eslint @typescript-eslint/no-use-before-define: 0 */
export class NavBarPage {
entityMenu = element(by.id('entity-menu'));
accountMenu = element(by.id('account-menu'));
adminMenu!: ElementFinder;
signIn = element(by.id('login'));
register = element(by.css('[routerLink="account/register"]'));
signOut = element(by.id('logout'));
passwordMenu = element(by.css('[routerLink="account/password"]'));
settingsMenu = element(by.css('[routerLink="account/settings"]'));
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
if (asAdmin) {
this.adminMenu = element(by.id('admin-menu'));
}
}
async clickOnEntityMenu(): Promise<void> {
await this.entityMenu.click();
}
async clickOnAccountMenu(): Promise<void> {
await this.accountMenu.click();
}
async clickOnAdminMenu(): Promise<void> {
await this.adminMenu.click();
}
async clickOnSignIn(): Promise<void> {
await this.signIn.click();
}
async clickOnRegister(): Promise<void> {
await this.signIn.click();
}
async clickOnSignOut(): Promise<void> {
await this.signOut.click();
}
async clickOnPasswordMenu(): Promise<void> {
await this.passwordMenu.click();
}
async clickOnSettingsMenu(): Promise<void> {
await this.settingsMenu.click();
}
async clickOnEntity(entityName: string): Promise<void> {
await element(by.css('[routerLink="' + entityName + '"]')).click();
}
async clickOnAdmin(entityName: string): Promise<void> {
await element(by.css('[routerLink="admin/' + entityName + '"]')).click();
}
async getSignInPage(): Promise<SignInPage> {
await this.clickOnAccountMenu();
await this.clickOnSignIn();
return new SignInPage();
}
async getPasswordPage(): Promise<PasswordPage> {
await this.clickOnAccountMenu();
await this.clickOnPasswordMenu();
return new PasswordPage();
}
async getSettingsPage(): Promise<SettingsPage> {
await this.clickOnAccountMenu();
await this.clickOnSettingsMenu();
return new SettingsPage();
}
async goToEntity(entityName: string): Promise<void> {
await this.clickOnEntityMenu();
await this.clickOnEntity(entityName);
}
async goToSignInPage(): Promise<void> {
await this.clickOnAccountMenu();
await this.clickOnSignIn();
}
async goToPasswordMenu(): Promise<void> {
await this.clickOnAccountMenu();
await this.clickOnPasswordMenu();
}
async autoSignOut(): Promise<void> {
await this.clickOnAccountMenu();
await this.clickOnSignOut();
}
}
export class SignInPage {
username = element(by.id('username'));
password = element(by.id('password'));
loginButton = element(by.css('button[type=submit]'));
async setUserName(username: string): Promise<void> {
await this.username.sendKeys(username);
}
async getUserName(): Promise<string> {
return this.username.getAttribute('value');
}
async clearUserName(): Promise<void> {
await this.username.clear();
}
async setPassword(password: string): Promise<void> {
await this.password.sendKeys(password);
}
async getPassword(): Promise<string> {
return this.password.getAttribute('value');
}
async clearPassword(): Promise<void> {
await this.password.clear();
}
async autoSignInUsing(username: string, password: string): Promise<void> {
await this.setUserName(username);
await this.setPassword(password);
await this.login();
}
async login(): Promise<void> {
await this.loginButton.click();
}
}
export class PasswordPage {
currentPassword = element(by.id('currentPassword'));
password = element(by.id('newPassword'));
confirmPassword = element(by.id('confirmPassword'));
saveButton = element(by.css('button[type=submit]'));
title = element.all(by.css('h2')).first();
async setCurrentPassword(password: string): Promise<void> {
await this.currentPassword.sendKeys(password);
}
async setPassword(password: string): Promise<void> {
await this.password.sendKeys(password);
}
async getPassword(): Promise<string> {
return this.password.getAttribute('value');
}
async clearPassword(): Promise<void> {
await this.password.clear();
}
async setConfirmPassword(confirmPassword: string): Promise<void> {
await this.confirmPassword.sendKeys(confirmPassword);
}
async getConfirmPassword(): Promise<string> {
return this.confirmPassword.getAttribute('value');
}
async clearConfirmPassword(): Promise<void> {
await this.confirmPassword.clear();
}
async getTitle(): Promise<string> {
return this.title.getAttribute('jhiTranslate');
}
async save(): Promise<void> {
await this.saveButton.click();
}
}
export class SettingsPage {
firstName = element(by.id('firstName'));
lastName = element(by.id('lastName'));
email = element(by.id('email'));
saveButton = element(by.css('button[type=submit]'));
title = element.all(by.css('h2')).first();
async setFirstName(firstName: string): Promise<void> {
await this.firstName.sendKeys(firstName);
}
async getFirstName(): Promise<string> {
return this.firstName.getAttribute('value');
}
async clearFirstName(): Promise<void> {
await this.firstName.clear();
}
async setLastName(lastName: string): Promise<void> {
await this.lastName.sendKeys(lastName);
}
async getLastName(): Promise<string> {
return this.lastName.getAttribute('value');
}
async clearLastName(): Promise<void> {
await this.lastName.clear();
}
async setEmail(email: string): Promise<void> {
await this.email.sendKeys(email);
}
async getEmail(): Promise<string> {
return this.email.getAttribute('value');
}
async clearEmail(): Promise<void> {
await this.email.clear();
}
async getTitle(): Promise<string> {
return this.title.getAttribute('jhiTranslate');
}
async save(): Promise<void> {
await this.saveButton.click();
}
}