Slide 1

Slide 1 text

‘25/02開催 とことんDevOps勉強会 2025年02月26日(水) 20:00より E2Eテスト自動化入門 ~テスト作成からGitHub Actionsでの 自動実行までやってみよう~

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

npm init playwright@latest

Slide 9

Slide 9 text

npm init playwright@latest tests/example.spec.ts ※

Slide 10

Slide 10 text

import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { await page.goto('https://playwright.dev/'); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); }); test('get started link', async ({ page }) => { await page.goto('https://playwright.dev/'); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); });

Slide 11

Slide 11 text

npx playwright test npx playwright test --project=chromium npx playwright test tests/example.spec.ts npx playwright test --ui

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Record new

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { await page.goto('https://playwright.dev/'); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); }); test('get started link', async ({ page }) => { await page.goto('https://playwright.dev/'); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); });

Slide 24

Slide 24 text

test('タイトル', async ({ page }) => { ... }); タイトル import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { // テストシナリオ1 }); test('get started link', async ({ page }) => { // テストシナリオ2 });

Slide 25

Slide 25 text

test('タイトル', async ({ page }) => { ... }); test('has title', async ({ page }) => { await page.goto('https://playwright.dev/'); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); });

Slide 26

Slide 26 text

page.goto() await page.goto('https://playwright.dev/');

Slide 27

Slide 27 text

.toHaveTitle() await expect(page).toHaveTitle(/Playwright/);

Slide 28

Slide 28 text

test('get started link', async ({ page }) => { await page.goto('https://playwright.dev/'); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); });

Slide 29

Slide 29 text

Slide 30

Slide 30 text

Installation page.getByRole('heading', { name: 'Installation' })

Installation expect() .toBeVisible() await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();

Slide 31

Slide 31 text

.getByRole() getByText() getByLabel() getByTestId() locator()

Slide 32

Slide 32 text

locator() #username username .btn btn button div > p div p await page.locator('#username').fill('my_username');