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

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


=== Mobile Device Emulator ===
=== Mobile Device Emulator ===
1. Create new file <code>tests/testMobile.spec.ts</code>
<nowiki>
import { test } from "@playwright/test"
test("input fields", async ({ page }, testInfo) => {
  await page.goto("/")
  const isMobile = testInfo.project.name === 'mobile'
  isMobile && await page.locator('.sidebar-toggle').click() // to show the sidebar which is hidden for mobile devices
  await page.getByText("Forms").click()
  await page.getByText("Form Layouts").click()
  isMobile && await page.locator('.sidebar-toggle').click()
  const usingTheGridEmailInput = page
    .locator("nb-card", { hasText: "Using the Grid" })
    .getByRole("textbox", { name: "Email" })
  await usingTheGridEmailInput.fill("test@test.com")
  await usingTheGridEmailInput.clear()
  await usingTheGridEmailInput.fill("test2@test.com")
})</nowiki>
2. Update <code>playwright.config.ts</code>
<nowiki>
export default defineConfig<TestOptions>({
  ...
  projects: [
    ...
    {
      name: "mobile",
      testMatch: "testMobile.spec.ts",
      use: {
      ...devices["iPhone 13 Pro"],
        // ..OR..
        // viewport: { width: 414, height: 800 },
      },
    },
  ],
})</nowiki>
=== Reporting ===
=== Reporting ===
=== Visual Testing ===
=== Visual Testing ===
=== Playwright with Docker Container ===
=== Playwright with Docker Container ===
=== Github Actions and Argos CI ===
=== Github Actions and Argos CI ===

Navigation menu