Playwright POC and Potential Challenges
POC Steps
Prerequisite and installation for Playwright Complete
https://playwright.dev/docs/getting-started-vscode
2. Self training Complete
https://www.lambdatest.com/blog/playwright-framework/
https://medium.com/geekculture/grouping-and-organising-test-suite-in-playwright-dccf2c55d776
3. Authentication
Testing Account setup
3.1 Receive a TC testing account Complete
3.2 Setup testing account in RSIG relative testing environment
3.2 Setup testing account in ROFS and assign roles
4. ROFS elements naming convention
Manager Review tab was confirmed by the team as the best candidate for POC. Most of the fields have done naming convention, but some elements, e.g. tab, pop-up window still could not be recognized if autorun.
5. Identify features/PBIs to create testing cases
Manager Review tab was confirmed by the team as the best candidate for POC. The linked document was created before authentication process implemented, so that modification is required.
6. Generating sample testing files
The following .ts document example was created for Manager Review before authentication process implemented, so that modification is required.
import { test, expect } from '@playwright/test';
test('test', async ({ page }) => {
//Login
await page.goto('https://rsig-test.azurewebsites.net/');
//await page.goto('https://rsig.azurewebsites.net/');
await page.getByPlaceholder('John.Smith@tc.gc.ca').fill('RSIGUSR@tc.gc.ca');
await page.getByPlaceholder('John.Smith@tc.gc.ca').press('Enter');
//SSO login
// await page.goto('https://sso1.gcsso.gc.ca/adfs/ls/wia?client-request-id=430f4c3b-25a5-4b15-aa74-cb5a98eab26e&wa=wsignin1.0&wtrealm=urn%3afederation%3aMicrosoftOnline&wctx=LoginOptions%3D3%26estsredirect%3d2%26estsrequest%3drQQIARAAlZPNi-N0GMeb6WydKegO7iqiCHNYQZS0eW8yItg2SZu2v_QladrmEpJf3psmbZK-nkW8ucdF8CJ6GRCWPYlePI-X9epRD8qCIuJhLwvb-RPkgQe-fD_wXD5P-YypEFjlOB8UiQp29QBnXQbHGQIlXdxCKc4lUc4iLJSzLZfhIMnYOJO-Xr74qHe3-e17b3Sv85_1R8-exNdI1c_zZXZVraZZ4KG5k-UV87BOna1jZcExVmInrx6rOIjRJLDh9wjyFEH-RJDrk4whWYylSYLGKY6scTUcq8xUOwSqR8mHeg5aY3wWYJgeikFP9XYyIeT6RJ7LqkSAUJ_PQn8u82Ikh0NaVoV8RgwP-pEHYePIR3NdHeeAAMRMHR7AYrjt81H068ndfn2d-8TtStLg4Px7cu4m6cJYJln-ZfGzYtPlO6xIYxIfWqLo8zlJNNqEtOdco-FOXdGio7FQ0-E8m4wV31Mpe9_sMWwGm0LdjEWJoWe4TQU2TZhRSnQishFLNRKtj9gE-KEyqLXDYSuhabFvRkZorhR2T6gcRvNhFvAw6jqcHDNKwjRoUezELaO9WC1qe7Iv1JSO0o9NqFhBl8oIbxdsZr7mZdQggNo6FIXMADV1zSj9qWhHWkvywwmDTvvRYbfn_A5oN3IIqB0ZTvXeHBtpwmDQ0Om9NY-EZa-u6QfedQebOAsaINcOdXe-E7uBsO90REgOOHMPttZA38z09lqRxwov0c7YX9iGYhkKTHlUVSJ3v8GU9cgbGjakFZUNkjm208DgANqk1iMdANdxd9o_aKtVP7PXeQCwLag76WABhVZ3kpkkPjKckSoZ3pPiAwLDWNc1ORQeVUQpm6uhnGlzKGVCh6BJlrGc2k3x3WTpxIF9uUwTN4icy8R1oyB2DBNCJ8t-K17cernO0k9yWPFgBZpPT5Fnp2-elS7uv1W4LLx_HytenZ2VLwq36fkp8vWdo-a_i03n7Xc24nef3nz1zX_3ijd3qgsKrnSum1jK1G22tMVy2_RmUX_ca0jDsOsvrTpJAqU-PB79mL7CH5aQh6V7N6VziTdkQWUM7J8S8vkrhR_O_-_DPCoj1-UPu5w41hLQOAJuW0vbIthNWYrryqv1ZDdZNIOtjw17NgY573EZ-enVwvPXXvzy9-Mv_vjxr_ZL0&cbcxt=&username=rsigusr%40tc.gc.ca&mkt=&lc=');
// await page.goto('https://login.microsoftonline.com/login.srf');
//Open ROFS Dashboard
await page.goto('https://rsig-test.azurewebsites.net/');
//await page.goto('https://rsig.azurewebsites.net/');
await page.waitForLoadState('networkidle');
await page.getByRole('link', { name: 'Dashboard' }).click();
await page.waitForLoadState('networkidle');
await expect(page).toHaveURL('https://rsig-test.azurewebsites.net/occurrences');
//await expect(page).toHaveURL('https://rsig.azurewebsites.net/occurrences');
const TSBOccuranceLink= page.locator("[data-label='TSB Occurrence']").first();
const TSBOccuranceId=await TSBOccuranceLink.textContent();
//Open an Occurance from data grid
await TSBOccuranceLink.click();
await expect(page).toHaveURL('https://rsig-test.azurewebsites.net/occurrence/'+TSBOccuranceId);
//await expect(page).toHaveURL('https://rsig.azurewebsites.net/occurrence/'+TSBOccuranceId);
//Open Manager Review tab
await page.locator("div .mud-tab").nth(1).click();
//await page.locator(".PlayWright-OccurenceManagerReviewTab").click();
await page.waitForLoadState('networkidle');
const managerReviewRadioMeetsMinCritYes =page.locator("[data-playwright='RegionalManagerReview-radioMeetsMinCritYes']");
const managerReviewRadioMeetsMinCritNo =page.locator("[data-playwright='RegionalManagerReview-radioMeetsMinCritNo']");
const managerReviewRadioReqestByManYes =page.locator("[data-playwright='RegionalManagerReview-radioReqestByManYes']");
const managerReviewRadioReqestByManNo =page.locator("[data-playwright='RegionalManagerReview-radioReqestByManNo']");
const managerReviewBtnRedo=page.locator("[data-playwright='RegionalManagerReview-btnRedo']");
const managerReviewBtnReAssign=page.locator("[data-playwright='RegionalManagerReview-btnReAssign']");
const managerReviewBtnSave=page.locator("[data-playwright='RegionalManagerReview-btnSave']");
const regionalManagerReviewTxtAssignedTodata=page.locator("[data-playwright='RegionalManagerReview-txtAssignedTo']");
const regionalManagerReviewTxtAssignmentNotes=page.locator("[data-playwright='RegionalManagerReview-txtAssignmentNotes']");
const regionalManagerReviewAssignToDialog=page.locator(".RegionalManagerReview-assignToDialog");
const regionalManagerReviewDialogBtnAssign=page.locator("[data-playwright='RegionalManagerReview-Dialog-btnAssign']");
//Scenario 1 : manager not reviewed, save as no inspection required
if(await managerReviewRadioMeetsMinCritYes.isEnabled() &&
await managerReviewRadioMeetsMinCritNo.isEnabled() &&
await managerReviewRadioReqestByManYes.isEnabled() &&
await managerReviewRadioReqestByManNo.isEnabled() &&
await managerReviewRadioMeetsMinCritNo.isChecked() &&
await managerReviewRadioReqestByManNo.isChecked()){
await expect(managerReviewBtnSave).toBeVisible();
await managerReviewBtnSave.click();
await expect(managerReviewRadioMeetsMinCritYes).toBeDisabled();
await expect(managerReviewRadioMeetsMinCritNo).toBeDisabled();
await expect(managerReviewRadioReqestByManYes).toBeDisabled();
await expect(managerReviewRadioReqestByManNo).toBeDisabled();
await expect(managerReviewBtnRedo).toBeVisible();
await expect(managerReviewBtnRedo).toBeEnabled();
await expect(managerReviewBtnReAssign).toBeVisible();
await expect(managerReviewBtnReAssign).toBeDisabled();
}
});
7. Testing RUN at local machine.
SSO still needs to be run manually, i.e. enter user name and password.
Click Manager Review tab and Assign RSI window cannot be executed automatically.
8. CI/CD integration with pilot testing files.