Newer
Older
import { element, by, ElementFinder, browser } 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"]'));
achievementsMenu = element(by.css('[routerLink="account/achievements"]'));
languageMenu = element(by.id('language'));
searchMenu = element(by.id('search'));
if (asAdmin) {
this.adminMenu = element(by.id('admin-menu'));
}
}
async clickOnEntityMenu(): Promise<void> {
await this.entityMenu.click();
}
async clickOnSearch(): Promise<void> {
await this.searchMenu.click();
}
async clickOnLanguageMenu(): Promise<void> {
await this.languageMenu.click();
}
async clickOnAccountMenu(): Promise<void> {
await this.accountMenu.click();
}
async clickOnAdminMenu(): Promise<void> {
await this.adminMenu.click();
}
async acceptDatapolicy(): Promise<void> {
await this.datapolicyCheckbox.click();
}
async clickOnLanguage(entityName: string): Promise<void> {
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();
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
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'));
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> {
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
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.id('saveSettings'));
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
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();
}
}