-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrud_test.js
More file actions
159 lines (136 loc) · 6.17 KB
/
crud_test.js
File metadata and controls
159 lines (136 loc) · 6.17 KB
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
const { faker } = require('@faker-js/faker');
Feature('crud_test');
Scenario('Test CRUD in Employee and Admin user', async ({ I, loginPage, addemployeePage, addAdminPage }) => {
const userid = 'Admin';
const password = 'admin123';
const fname = faker.person.firstName();
const lname = faker.person.lastName();
const EmployName = fname + ' ' + lname;
const username = 'admin' + lname;
let EmployNumb = faker.number.int({ min: 100000000, max: 999999999 })
//Precondition: An Employee must be created in PIM before it can be assigned as an Admin user"
//GIVEN I have the admin credentials to the orangehrmlive portal and create and edit a new employee.
I.amOnPage('https://opensource-demo.orangehrmlive.com/web/index.php/auth/login');
//I.waitForElement('.orangehrm-login-title', 20);
//I.waitForElement({css: 'div.orangehrm-login-slot'}, 20);
//I.waitForElement({css: '.oxd-text.oxd-text--h5.orangehrm-login-title'}, 20);
I.waitForElement({css: '.orangehrm-login-title'}, 20);
I.see('Login');
loginPage.sendForm(userid, secret(password));
I.wait(5);
I.waitForElement({css: 'div.oxd-topbar-header-title'}, 20);
I.see('Dashboard');
//WHEN I Navigate to "PIM" on the side navigation bar.
I.click('PIM', {css: 'div.oxd-sidepanel-body'});
I.waitForElement({css: 'div.oxd-table-filter-header-title'}, 20);
I.see('Employee Information');
//AND I Click on "Add."
I.click('Add', {css: 'div.orangehrm-header-container'}); //add button
//I.click({css: 'button.oxd-button--secondary:nth-child(1)'});
I.waitForElement({css: 'div.oxd-layout-context'}, 20);
I.see('Add Employee');
//AND I create a new employee
I.wait(3);
addemployeePage.sendForm(fname, lname, EmployNumb);
I.wait(5);
I.waitForElement({css: 'div.orangehrm-horizontal-padding.orangehrm-vertical-padding'}, 20);
I.see('Personal Details');
//AND I search the new employee
I.click('PIM', {css: 'div.oxd-sidepanel-body'});
I.waitForElement({css: 'div.oxd-table-filter-header-title'}, 20);
I.see('Employee Information');
I.fillField({css: 'div:nth-child(1) > div > div:nth-child(2) > div > div > input'}, EmployName);
I.wait(3);
I.pressKey('ArrowDown');
I.pressKey('Enter');
I.click({css: 'button.oxd-button:nth-child(2)'}); //Search button
I.wait(3);
I.see(EmployNumb);
//THEN I edit the new employee
I.click({css: 'button.oxd-table-cell-action-space:nth-child(1)'}); //edit button
I.waitForElement({css: 'div.orangehrm-horizontal-padding.orangehrm-vertical-padding'}, 20);
I.wait(3);
I.see('Personal Details');
I.see(EmployName);
I.doubleClick({css: 'div.oxd-form-row:nth-child(3) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > input:nth-child(1)'});
I.pressKey('Backspace');
EmployNumb = faker.number.int({ min: 100000000, max: 999999999 }) //new Employee Id
I.fillField({css: 'div.oxd-form-row:nth-child(3) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > input:nth-child(1)'}, EmployNumb); //Update Employee Id field
I.click('Save', {css: 'div.orangehrm-horizontal-padding.orangehrm-vertical-padding'});
I.wait(5);
I.click('PIM', {css: 'div.oxd-sidepanel-body'});
I.waitForElement({css: 'div.oxd-table-filter-header-title'}, 20);
I.see('Employee Information');
I.fillField({css: 'div:nth-child(1) > div > div:nth-child(2) > div > div > input'}, EmployName);
I.wait(3);
I.pressKey('ArrowDown');
I.pressKey('Enter');
I.click({css: 'button.oxd-button:nth-child(2)'}); //Search button
I.wait(3);
I.see(EmployNumb); //View new Employee Id
//GIVEN I have the admin credentials to assign a new employee as an Admin User.
//WHEN I navigate to "Admin" on the side navigation bar.
I.click('Admin', {css: 'div.oxd-sidepanel-body'}); //Admin menu
I.wait(3);
I.waitForElement({css: 'div.oxd-table-filter-header-title'}, 20);
I.see('System Users');
//AND I assign the new employee as an Admin User
I.click('Add', {css: 'div.orangehrm-header-container'}); //add button
I.waitForElement({css: 'div.oxd-layout-context'}, 20);
I.wait(3);
I.see('Add User');
addAdminPage.sendForm(EmployName, username, secret(password), secret(password));
I.wait(10);
I.waitForElement({css: 'div.oxd-table-filter-header-title'}, 20);
I.see('System Users');
//AND I search the the new Admin User
I.fillField({css: 'input.oxd-input:nth-child(1)'}, username); //User Name field
I.click({css: 'button.oxd-button:nth-child(2)'}); //Search button
I.wait(3);
I.see(EmployName);
//AND I edit the new admin user
I.click({css: 'button.oxd-icon-button:nth-child(2)'}); //edit button
I.waitForElement({css: 'div.oxd-input-group__label-wrapper'}, 20);
I.wait(5);
I.see('Edit User');
I.click({css: 'div:nth-child(3) > div > div:nth-child(2) > div > div > div.oxd-select-text--after'}); //Status select button
for (i = 1; i <= 2; i++) {
I.pressKey('ArrowDown');
}
I.pressKey('Enter'); //Update to disabled
I.click({css: 'button.oxd-button:nth-child(3)'}); //Save button
I.waitForElement({css: 'div.oxd-table-filter-header-title'}, 20);
I.wait(5);
I.see('System Users');
I.fillField({css: 'input.oxd-input:nth-child(1)'}, username); //User Name field
I.click({css: 'button.oxd-button:nth-child(2)'}); //Search button
I.wait(5);
I.see(EmployName);
I.see('Disabled'); // View the Admin with the updated status to Disabled
//THEN I delete the Admin role for the new employee
I.click({css: 'button.oxd-table-cell-action-space:nth-child(1)'}); //Delete button
I.wait(1);
I.click('Yes, Delete'); //Yes, Delete button
I.wait(5);
I.click({css: 'button.oxd-button:nth-child(2)'}); //Search button
I.wait(3);
I.dontSee(EmployName);
//AND I delete the new employee
I.click('PIM', {css: 'div.oxd-sidepanel-body'});
I.waitForElement({css: 'div.oxd-table-filter-header-title'}, 20);
I.see('Employee Information');
I.fillField({css: 'div:nth-child(1) > div > div:nth-child(2) > div > div > input'}, EmployName);
I.wait(3);
I.pressKey('ArrowDown');
I.pressKey('Enter');
I.click({css: 'button.oxd-button:nth-child(2)'}); //Search button
I.wait(3);
I.see(EmployNumb);
I.click({css: 'button.oxd-icon-button:nth-child(2)'}); //Delete button
I.wait(1);
I.click('Yes, Delete'); //Yes, Delete button
I.wait(5);
I.click({css: 'button.oxd-button:nth-child(2)'}); //Search button
I.wait(3);
I.dontSee(EmployNumb);
});