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 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