Udemy Playwright: Web Automation Testing From Zero to Hero: Difference between revisions

Jump to navigation Jump to search
m
Line 1,437: Line 1,437:


=== Test Data Generator ===
=== Test Data Generator ===
Install faker with <code>npm i @faker-js/faker --save-dev --force</code> (force because it has several CVE's)
Update test in <code>tests\usePageObjects.spec.ts</code>
<nowiki>
test("Page Manger", async ({ page }) => {
  const pm = new PageManager(page)
  const randomFullName = faker.person.fullName({
    // sex: "male",      // specify sex (optional)
    // lastName: "Johns", // specify last name (optional)
  })
  const randomEmail = `${randomFullName.replace(/ /g, "")}${faker.number.int(
    1000
  )}@test.com`
  await pm.navigateTo().formLayoutsPage()
  await pm
    .onFormLayoutsPage()
    .submitUsingTheGridFormWithCredentialsAndSelectOption(
      "test@test.com",
      "Welcome1",
      "Option 2"
    )
  await pm
    .onFormLayoutsPage()
    .submitInLineFormWithNameEmailAndCheckbox(randomFullName, randomEmail, true)
  await pm.navigateTo().datePickerPage()
  await pm.onDatePickerPage().selectCommonDatePickerDateFromToday(10)
  await pm.onDatePickerPage().selectDatePickerWithRangeFromToday(6, 15)
})</nowiki>
Notes:
* The faker fullName() method can sometimes add title prefixes, suffixes, etc., which look very odd in email addresses ....
=== Test Retries ===
=== Test Retries ===
=== Parallel Execution ===
=== Parallel Execution ===

Navigation menu