|
@@ -0,0 +1,347 @@
|
|
|
|
+const {test, expect} = require('@playwright/test');
|
|
|
|
+const { Console } = require('console');
|
|
|
|
+const exp = require('constants');
|
|
|
|
+const { copyFileSync } = require('fs');
|
|
|
|
+
|
|
|
|
+test('Login page', async({page})=>{
|
|
|
|
+
|
|
|
|
+ const menuListItemName = 'PIM';
|
|
|
|
+ const pim_menu_AddEmp = 'Add Employee';
|
|
|
|
+
|
|
|
|
+ // Increase the default timeout for this test
|
|
|
|
+ test.setTimeout(2000000);
|
|
|
|
+
|
|
|
|
+ //hitting the testing URL
|
|
|
|
+ await page.goto('https://testingone-osondemand.orangehrm.com/auth/login');
|
|
|
|
+
|
|
|
|
+ //Locators
|
|
|
|
+ const loginUserNameField = await page.locator('[name="username"]');
|
|
|
|
+ const loginPasswordField = await page.locator('[type="password"]');
|
|
|
|
+ const loginButton = await page.locator('[type="submit"]');
|
|
|
|
+
|
|
|
|
+ // Login page -- check error message after enter invalid credentials
|
|
|
|
+ await loginUserNameField.fill('XYZ');
|
|
|
|
+ await loginPasswordField.fill('XYZ112')
|
|
|
|
+ await loginButton.click();
|
|
|
|
+ console.log('Error message is: ',await page.locator('.oxd-alert-content--error p').textContent());
|
|
|
|
+ await expect(await page.locator('.oxd-alert-content--error p')).toContainText('Invalid credentials');
|
|
|
|
+
|
|
|
|
+ //Checking and clicking on the forgot password link
|
|
|
|
+ const forgotLocator = await page.locator('.orangehrm-login-forgot-header');
|
|
|
|
+ const forgotTextLink = await forgotLocator.textContent();
|
|
|
|
+ await console.log('Forgot password Link Text',forgotTextLink);
|
|
|
|
+ console.log(await forgotLocator.isVisible()); // -- O/p -- True
|
|
|
|
+ await expect(await forgotLocator.isVisible()).toBeTruthy(); // -- checking it is correct or not
|
|
|
|
+ await forgotLocator.click();
|
|
|
|
+
|
|
|
|
+ const forgotPage = await page.locator('.orangehrm-forgot-password-title');
|
|
|
|
+ await forgotPage.waitFor();
|
|
|
|
+ console.log(await forgotPage.isVisible());
|
|
|
|
+ await expect(await forgotPage.isVisible()).toBeTruthy();
|
|
|
|
+
|
|
|
|
+ const forgotMsg = await page.locator('.orangehrm-card-note-text');
|
|
|
|
+ const forgotMsgText = await forgotMsg.textContent();
|
|
|
|
+ console.log(forgotMsgText);
|
|
|
|
+ console.log(await forgotMsg.isVisible());
|
|
|
|
+ await expect(await forgotMsg.isVisible()).toBeTruthy();
|
|
|
|
+
|
|
|
|
+ //going back to the login page
|
|
|
|
+ await page.goBack();
|
|
|
|
+ await loginUserNameField.waitFor();
|
|
|
|
+ await loginUserNameField.fill('Admin');
|
|
|
|
+ await loginPasswordField.fill('Ishir@123')
|
|
|
|
+ await loginButton.click();
|
|
|
|
+
|
|
|
|
+ //On Dashboard page check the loggedin user name
|
|
|
|
+ await page.locator('.oxd-userdropdown-name').waitFor();
|
|
|
|
+ console.log('Is User name is visibe on the page');
|
|
|
|
+ console.log(await page.locator('.oxd-userdropdown-name').isVisible());
|
|
|
|
+ const loggedUserName = await page.locator('.oxd-userdropdown-name').textContent();
|
|
|
|
+ console.log('Logged in User Name is: ', loggedUserName);
|
|
|
|
+ await expect(loggedUserName === 'Testing One').toBeTruthy();
|
|
|
|
+
|
|
|
|
+ // PIM
|
|
|
|
+ //await page.waitForTimeout(3000);
|
|
|
|
+ const navBarList = await page.locator('.oxd-main-menu li span');
|
|
|
|
+ const menuItemCount = await navBarList.count();
|
|
|
|
+ console.log(menuItemCount);
|
|
|
|
+ for(let i=0; i<menuItemCount; i++){
|
|
|
|
+ const menuItemName = await navBarList.nth(i).textContent();
|
|
|
|
+ if(menuItemName === menuListItemName){
|
|
|
|
+ await navBarList.nth(i).click();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //PIM menu i.e. clicking on "Add Employee" link
|
|
|
|
+ await page.waitForTimeout(3000);
|
|
|
|
+ const menuItemList = await page.locator('.oxd-topbar-body-nav ul li a');
|
|
|
|
+ const menuItemListCount = await menuItemList.count();
|
|
|
|
+ for(let i=0; i<menuItemListCount; i++){
|
|
|
|
+ const menuText = await menuItemList.nth(i).textContent();
|
|
|
|
+ if(menuText === pim_menu_AddEmp){
|
|
|
|
+ await await menuItemList.nth(i).click();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //uploading image
|
|
|
|
+ await page.locator('input[type="file"]').setInputFiles('Amy_Acker.png');
|
|
|
|
+
|
|
|
|
+ //PIM menu i.e. Filling the "Add Employee" form
|
|
|
|
+ await page.locator('.orangehrm-employee-form [name="firstName"]').pressSequentially('Amy1');
|
|
|
|
+ await page.locator('.orangehrm-employee-form [name="lastName"]').pressSequentially('Acker1');
|
|
|
|
+ await page.locator('.--label-right').click();
|
|
|
|
+
|
|
|
|
+ await page.locator('.oxd-form-row input[class="oxd-input oxd-input--active"]').nth(1).pressSequentially('Amy_Acker1');
|
|
|
|
+ await page.locator('.oxd-form-row input[type="password"]').nth(0).pressSequentially('Ishir@123');
|
|
|
|
+ await page.locator('.oxd-form-row input[type="password"]').nth(1).pressSequentially('Ishir@123');
|
|
|
|
+
|
|
|
|
+ await page.locator('button[type="submit"]').click();
|
|
|
|
+
|
|
|
|
+ await page.waitForTimeout(2000);
|
|
|
|
+
|
|
|
|
+ // I am clicking on the Employee List tab and find the User
|
|
|
|
+
|
|
|
|
+ const EmpListMenu = await page.locator('.oxd-topbar-body-nav-tab-item').nth(1);
|
|
|
|
+ await EmpListMenu.click();
|
|
|
|
+
|
|
|
|
+ //finding the newly created user in the list not with the help of search functionlality
|
|
|
|
+ await page.locator('.oxd-table-card').first().waitFor();
|
|
|
|
+ const numRows = await page.locator('.oxd-table-card');
|
|
|
|
+ const numRowsCount = await numRows.count();
|
|
|
|
+ console.log('Number of Users: ',numRowsCount);
|
|
|
|
+ for(let i=0; i<numRowsCount; i++){
|
|
|
|
+ const nthRow = await numRows.nth(i);
|
|
|
|
+ const cell = await nthRow.locator('.oxd-padding-cell').nth(1);
|
|
|
|
+ const cellText = await cell.locator('div').textContent();
|
|
|
|
+ if(cellText ==='0004'){
|
|
|
|
+ console.log('Id is okay');
|
|
|
|
+ const cell = await nthRow.locator('.oxd-padding-cell').nth(2);
|
|
|
|
+ const cellText = await cell.locator('div').textContent();
|
|
|
|
+ if(cellText==='Amy1 '){
|
|
|
|
+ console.log('First Name is okay');
|
|
|
|
+ const cell = await nthRow.locator('.oxd-padding-cell').nth(3);
|
|
|
|
+ const cellText = await cell.locator('div').textContent();
|
|
|
|
+ if(cellText==='Acker1'){
|
|
|
|
+ console.log('Laste Name is okay');
|
|
|
|
+ await nthRow.locator('.oxd-padding-cell .bi-pencil-fill').nth(0).click();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ //Personal Details -- Driver's License Number
|
|
|
|
+ await page.locator('input[placeholder="First Name"]').waitFor();
|
|
|
|
+ await page.waitForTimeout(2000);
|
|
|
|
+ await page.locator('.oxd-input').nth(6).pressSequentially('Driv123456789');
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// Personal Details -- License Expiry Date -- Year
|
|
|
|
+const calen1 = await page.locator('.bi-calendar').first().click();
|
|
|
|
+let LicensecalYearLocatorText = parseInt(await page.locator('.oxd-calendar-selector-year-selected p').textContent());
|
|
|
|
+console.log(LicensecalYearLocatorText);
|
|
|
|
+if (LicensecalYearLocatorText < 2027) {
|
|
|
|
+ while (LicensecalYearLocatorText < 2027) {
|
|
|
|
+ await page.locator('.bi-chevron-right').click();
|
|
|
|
+ LicensecalYearLocatorText = parseInt(await page.locator('.oxd-calendar-selector-year-selected p').textContent());
|
|
|
|
+ if (LicensecalYearLocatorText === 2027) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// Personal Details -- License Expiry Date -- Month
|
|
|
|
+await page.locator('.oxd-calendar-selector-month-selected .bi-caret-down-fill').click();
|
|
|
|
+const monthdropdown = await page.locator('.oxd-calendar-dropdown .oxd-calendar-dropdown--option');
|
|
|
|
+const monthdropdownCount = await monthdropdown.count();
|
|
|
|
+for(let i=0; i<monthdropdownCount; i++){
|
|
|
|
+ const monthdropdownText = await monthdropdown.nth(i).textContent();
|
|
|
|
+ if(monthdropdownText === 'May'){
|
|
|
|
+ await monthdropdown.nth(i).click();
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//Date
|
|
|
|
+const calDateLocator = await page.locator('.oxd-calendar-date-wrapper .oxd-calendar-date');
|
|
|
|
+await calDateLocator.nth(19).click();
|
|
|
|
+
|
|
|
|
+//Nationalty
|
|
|
|
+const Nationality_drop = await page.locator('.oxd-select-text--arrow').first();
|
|
|
|
+const Nationality_dropClick = await Nationality_drop.click();
|
|
|
|
+const Nationalityoption = await page.locator('.oxd-select-option', { hasText: 'American' });
|
|
|
|
+await Nationalityoption.click();
|
|
|
|
+
|
|
|
|
+//Marital Status
|
|
|
|
+const mariatlStatus = await page.locator('.oxd-select-text--arrow').last();
|
|
|
|
+const mariatlStatusClick = await mariatlStatus.click();
|
|
|
|
+const mariatlStatusoption = await page.locator('.oxd-select-option', { hasText: 'Married' });
|
|
|
|
+await mariatlStatusoption.click();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// Personal Details -- User Date of Birth -- Year
|
|
|
|
+
|
|
|
|
+const calen2 = await page.locator('.bi-calendar').last().click();
|
|
|
|
+let dobLocatorText = parseInt(await page.locator('.oxd-calendar-selector-year-selected p').textContent());
|
|
|
|
+console.log(dobLocatorText);
|
|
|
|
+if (dobLocatorText > 2022) {
|
|
|
|
+ while (dobLocatorText > 2022) {
|
|
|
|
+ await page.locator('.bi-chevron-left').last().click();
|
|
|
|
+ let dobLocatorText = parseInt(await page.locator('.oxd-calendar-selector-year-selected p').textContent());
|
|
|
|
+ if (dobLocatorText === 2022) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// Personal Details -- DOB -- Month
|
|
|
|
+await page.locator('.oxd-calendar-selector-month-selected .bi-caret-down-fill').click();
|
|
|
|
+const monthdropdown1 = await page.locator('.oxd-calendar-dropdown .oxd-calendar-dropdown--option');
|
|
|
|
+const monthdropdownCount1 = await monthdropdown1.count();
|
|
|
|
+for(let i=0; i<monthdropdownCount1; i++){
|
|
|
|
+ const monthdropdownText = await monthdropdown1.nth(i).textContent();
|
|
|
|
+ if(monthdropdownText === 'May'){
|
|
|
|
+ await monthdropdown1.nth(i).click();
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//DOB - Date
|
|
|
|
+const calDateLocator1 = await page.locator('.oxd-calendar-date-wrapper .oxd-calendar-date');
|
|
|
|
+await calDateLocator1.nth(19).click();
|
|
|
|
+
|
|
|
|
+//Gender
|
|
|
|
+await page.locator('.--gender-grouped-field label').last().click();
|
|
|
|
+
|
|
|
|
+// Clicking on the save button of the Form
|
|
|
|
+await page.locator('.orangehrm-left-space').click();
|
|
|
|
+
|
|
|
|
+//Attaching a file & Upload file
|
|
|
|
+await page.locator('.oxd-button--medium').last().click();
|
|
|
|
+await page.locator('input[type="file"]').setInputFiles('Amy_Acker.png');
|
|
|
|
+
|
|
|
|
+//adding comment
|
|
|
|
+await page.locator(' textarea[placeholder="Type comment here"]').pressSequentially('Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type.');
|
|
|
|
+
|
|
|
|
+//Clicking on save button after upload a file
|
|
|
|
+await page.locator('button[type="submit"]').last().click();
|
|
|
|
+
|
|
|
|
+//await page.pause();
|
|
|
|
+
|
|
|
|
+//Going to the Admin page i.e. clicking on Admin menue
|
|
|
|
+const menus = await page.locator('.oxd-main-menu-item--name');
|
|
|
|
+ const menusCount = await menus.count();
|
|
|
|
+ for(let i=0; i<menusCount; i++){
|
|
|
|
+ const menusText = await menus.nth(i).textContent();
|
|
|
|
+ if(menusText=== 'Admin'){
|
|
|
|
+ await menus.nth(i).click();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+//Search functionlaity -- by filter option
|
|
|
|
+//Enter User Name in the seach section
|
|
|
|
+//await page.locator('.oxd-form-row .oxd-input--active').waitFor();
|
|
|
|
+await page.locator('.oxd-form-row .oxd-input--active').pressSequentially('Amy_Acker1');
|
|
|
|
+
|
|
|
|
+//User role drop-down in the search section
|
|
|
|
+await page.locator('.oxd-select-text--arrow').first().click();
|
|
|
|
+//await page.locator('.oxd-select-dropdown .oxd-select-option').waitFor();
|
|
|
|
+//////await page.waitForTimeout(2000);
|
|
|
|
+const optionLocatorFirst = await page.locator('.oxd-select-dropdown .oxd-select-option');
|
|
|
|
+const optionCount = await optionLocatorFirst.count();
|
|
|
|
+for(let i=0; i<optionCount; i++){
|
|
|
|
+ const optionName1 = await optionLocatorFirst.locator('span').nth(i).textContent();
|
|
|
|
+ if(optionName1 === 'ESS'){
|
|
|
|
+ await optionLocatorFirst.locator('span').nth(i).click();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//Employee Name
|
|
|
|
+const empName = await page.locator('[placeholder="Type for hints..."]').first();
|
|
|
|
+await empName.click();
|
|
|
|
+await empName.pressSequentially('Amy');
|
|
|
|
+await page.waitForTimeout(2000);
|
|
|
|
+const dropMenus = await page.locator('.oxd-autocomplete-dropdown .oxd-autocomplete-option');
|
|
|
|
+const dropMenusCount = await dropMenus.count();
|
|
|
|
+for(let i=0; i<dropMenusCount; i++){
|
|
|
|
+ const dropMenuText = await dropMenus.nth(i).textContent();
|
|
|
|
+ if(dropMenuText=== 'Amy1 Acker1' ){
|
|
|
|
+ await dropMenus.nth(i).click();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//Check status
|
|
|
|
+await page.locator('.oxd-select-text--arrow').last().click();
|
|
|
|
+const optionLocator = await page.locator('.oxd-select-dropdown .oxd-select-option');
|
|
|
|
+const optionCount1 = await page.locator('.oxd-select-dropdown .oxd-select-option').count();
|
|
|
|
+for(let i=0; i<optionCount1; i++){
|
|
|
|
+ const optionName1 = await optionLocator.locator('span').nth(i).textContent();
|
|
|
|
+ if(optionName1 === 'Enabled'){
|
|
|
|
+ await optionLocator.locator('span').nth(i).click();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+await page.locator('.orangehrm-left-space').click();
|
|
|
|
+
|
|
|
|
+//Again clicking on the PIM menu button
|
|
|
|
+ const navBarList1 = await page.locator('.oxd-main-menu li span');
|
|
|
|
+ const menuItemCount1 = await navBarList1.count();
|
|
|
|
+ console.log(menuItemCount1);
|
|
|
|
+ for(let i=0; i<menuItemCount1; i++){
|
|
|
|
+ const menuItemName = await navBarList1.nth(i).textContent();
|
|
|
|
+ if(menuItemName === menuListItemName){
|
|
|
|
+ await navBarList1.nth(i).click();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+//finding the newly created user in the PIM list not with the help of search functionlality - Delete the user
|
|
|
|
+await page.locator('.oxd-table-card').first().waitFor();
|
|
|
|
+const numRows2 = await page.locator('.oxd-table-card');
|
|
|
|
+const numRowsCount2 = await numRows2.count();
|
|
|
|
+console.log('Number of Users: ',numRowsCount2);
|
|
|
|
+for(let i=0; i<numRowsCount2; i++){
|
|
|
|
+ const nthRow = await numRows2.nth(i);
|
|
|
|
+ const cell = await nthRow.locator('.oxd-padding-cell').nth(1);
|
|
|
|
+ const cellText = await cell.locator('div').textContent();
|
|
|
|
+ if(cellText ==='0003'){
|
|
|
|
+ console.log('Id is okay');
|
|
|
|
+ const cell = await nthRow.locator('.oxd-padding-cell').nth(2);
|
|
|
|
+ const cellText = await cell.locator('div').textContent();
|
|
|
|
+ if(cellText==='Amy1 '){
|
|
|
|
+ console.log('First Name is okay');
|
|
|
|
+ const cell = await nthRow.locator('.oxd-padding-cell').nth(3);
|
|
|
|
+ const cellText = await cell.locator('div').textContent();
|
|
|
|
+ if(cellText==='Acker1'){
|
|
|
|
+ console.log('Laste Name is okay');
|
|
|
|
+ await nthRow.locator('.oxd-padding-cell .bi-trash').nth(0).click();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//Delete the newwly created user form the PIM
|
|
|
|
+await page.locator('.orangehrm-dialog-popup .orangehrm-button-margin').last().click();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+await page.pause();
|
|
|
|
+
|
|
|
|
+})
|