├── .github
└── poster.png
├── .gitignore
├── Readme.md
├── package.json
└── tests
└── example.spec.ts
/.github/poster.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qaxperience/playwright-actions-template/d470cb14d41274c9fbb364f10ed677406792fa6c/.github/poster.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | cypress/videos
3 | cypress/screenshots
4 | results
5 | results/*.xml
6 | /test-results/
7 | /playwright-report/
8 | /playwright/.cache/
9 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | ## Sobre
4 |
5 | Repositório do treinamento: Workflow de testes contínuos em Playwright no Github Actions
6 |
7 | ## Stacks
8 | - Playwright
9 | - TypeScript
10 | - Tesults
11 |
12 | ## Rodando
13 |
14 | 1. Clonar o repositório, instalar as dependências
15 | ```
16 | npm install
17 | ```
18 |
19 | 2. Executar testes em Headless
20 | ```
21 | npx playwright test
22 | ```
23 |
24 | 3. Executar ver o relatório dos testes
25 | ```
26 | npx playwright show-report
27 | ```
28 |
29 |
30 | Curso disponível em https://qaxperience.com
31 |
32 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "login-xp-playwright",
3 | "version": "1.0.0",
4 | "description": "Projeto de testes de login com Playwright",
5 | "main": "index.js",
6 | "directories": {
7 | "test": "tests"
8 | },
9 | "scripts": {
10 | "test": "echo \"Error: no test specified\" && exit 1"
11 | },
12 | "author": "Fernando Papito",
13 | "license": "MIT"
14 | }
15 |
--------------------------------------------------------------------------------
/tests/example.spec.ts:
--------------------------------------------------------------------------------
1 | import { test, expect, Page } from '@playwright/test';
2 |
3 | test('usuário obrigatório', async ({ page }) => {
4 | await login(page, '', 'senha123')
5 | await toast(page, 'Informe o seu nome de usuário!s')
6 | });
7 |
8 | test('senha obrigatória', async ({ page }) => {
9 | await login(page,'qa', '')
10 | await toast(page, 'Informe a sua senha secreta!')
11 | })
12 |
13 | test('usuário não existe', async ({ page }) => {
14 | await login(page,'teste', 'teste')
15 | await toast(page, 'Oops! Credenciais inválidas :(')
16 | })
17 |
18 | test('senha incorreta', async ({ page }) => {
19 | await login(page,'qa', 'teste')
20 | await toast(page, 'Oops! Credenciais inválidas :(')
21 | })
22 |
23 | test('com sucesso', async ({ page }) => {
24 | await login(page,'qa', 'xperience')
25 | await modal(page, 'Suas credenciais são válidas :)')
26 | })
27 |
28 | const toast = async (page: Page, message: string) => {
29 | const target = page.locator('div[role=status]')
30 | await expect(target).toHaveText(message);
31 | }
32 |
33 | const modal = async (page: Page, message: string) => {
34 | const target = page.locator('.swal2-html-container')
35 | await expect(target).toHaveText(message);
36 | }
37 |
38 | const login = async (page: Page, user: string, pass: string) => {
39 | await page.goto('/')
40 |
41 | const username = page.locator('[name=user]')
42 | const password = page.locator('[name=pass]')
43 |
44 | user
45 | ? await username.fill(user) : null
46 |
47 | pass
48 | ? await password.fill(pass) : null
49 |
50 | await page.click('css=button >> text=Entrar')
51 | }
52 |
53 |
--------------------------------------------------------------------------------