1 import { by, element } from 'protractor';
2 import { PageHelper } from '../page-helper.po';
4 export class UserMgmtPageHelper extends PageHelper {
6 index: '/#/user-management/users',
7 create: '/#/user-management/users/create'
10 async create(username: string, password: string, name: string, email: string): Promise<void> {
11 await this.navigateTo('create');
14 await element(by.id('username')).sendKeys(username);
15 await element(by.id('password')).sendKeys(password);
16 await element(by.id('confirmpassword')).sendKeys(password);
17 await element(by.id('name')).sendKeys(name);
18 await element(by.id('email')).sendKeys(email);
20 // Click the create button and wait for user to be made
21 const createButton = element(by.cssContainingText('button', 'Create User'));
22 await createButton.click();
23 await this.waitPresence(this.getFirstTableCellWithText(username));
26 async edit(username: string, password: string, name: string, email: string): Promise<void> {
27 await this.navigateTo();
29 await this.getFirstTableCellWithText(username).click(); // select user from table
30 await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page
32 // fill in fields with new values
33 await element(by.id('password')).clear();
34 await element(by.id('password')).sendKeys(password);
35 await element(by.id('confirmpassword')).clear();
36 await element(by.id('confirmpassword')).sendKeys(password);
37 await element(by.id('name')).clear();
38 await element(by.id('name')).sendKeys(name);
39 await element(by.id('email')).clear();
40 await element(by.id('email')).sendKeys(email);
42 // Click the edit button and check new values are present in table
43 const editButton = element(by.cssContainingText('button', 'Edit User'));
44 await editButton.click();
45 await this.waitPresence(this.getFirstTableCellWithText(email));
46 await this.waitPresence(this.getFirstTableCellWithText(name));