You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Aquí tienes un ejemplo de un archivo README.md para un proyecto de Playwright con Allure en TypeScript. Incluye información sobre el propósito del proyecto, el uso del Page Object Model (POM), la integración con Allure, cómo ver reportes, y una lista de comandos útiles, incluyendo --ui.
2
-
Proyecto de Automatización con Playwright, TypeScript y Allure
3
-
Este proyecto implementa pruebas automatizadas de interfaz de usuario usando Playwright con TypeScript como lenguaje principal y Allure para la generación de reportes detallados. El enfoque sigue el patrón Page Object Model (POM) para mantener las pruebas organizadas, mantenibles y reutilizables.
4
-
Propósito
1
+
# README - Playwright Automation Project with TypeScript and Allure
2
+
3
+
## English
4
+
5
+
### Project Overview
6
+
This project implements automated UI tests using Playwright with TypeScript as the primary language and Allure for generating detailed reports. The approach follows the Page Object Model (POM) to keep tests organized, maintainable, and reusable.
7
+
8
+
### Purpose
9
+
Automate functional tests for a web application (e.g., a form at https://v0-classic-registration-form-u8ghow.vercel.app/) to validate behaviors such as:
10
+
- Required and optional fields.
11
+
- Format validations (email, phone).
12
+
- Success or error messages after form submission.
13
+
14
+
### Technologies Used
15
+
-**Playwright**: Browser automation tool.
16
+
-**TypeScript**: Statically typed language for better maintainability.
17
+
-**Allure**: Generates visual and interactive reports.
18
+
-**Node.js**: Execution environment.
19
+
20
+
### Project Structure
21
+
```
22
+
project-root/
23
+
├── Pages/ # POM classes for pages
24
+
│ └── FormPage.ts # Example: Class to interact with the form
25
+
├── tests/ # Test files
26
+
│ └── registration.spec.ts # Test cases for the form
Este proyecto implementa pruebas automatizadas de interfaz de usuario utilizando Playwright con TypeScript como lenguaje principal y Allure para la generación de reportes detallados. El enfoque sigue el patrón Page Object Model (POM) para mantener las pruebas organizadas, mantenibles y reutilizables.
95
+
96
+
### Propósito
5
97
Automatizar pruebas funcionales en una aplicación web (por ejemplo, un formulario en https://v0-classic-registration-form-u8ghow.vercel.app/) para validar comportamientos como:
6
-
Campos obligatorios y no obligatorios.
7
-
Validaciones de formato (email, teléfono).
8
-
Mensajes de éxito o error tras el envío del formulario.
9
-
Tecnologías
10
-
Playwright: Herramienta de automatización de navegadores.
11
-
TypeScript: Lenguaje para tipado estático y mejor mantenibilidad.
12
-
Allure: Generación de reportes visuales e interactivos.
13
-
Node.js: Entorno de ejecución.
14
-
Estructura del Proyecto
98
+
- Campos obligatorios y opcionales.
99
+
- Validaciones de formato (correo electrónico, teléfono).
100
+
- Mensajes de éxito o error tras el envío del formulario.
101
+
102
+
### Tecnologías Usadas
103
+
-**Playwright**: Herramienta de automatización de navegadores.
104
+
-**TypeScript**: Lenguaje con tipado estático para mejor mantenibilidad.
105
+
-**Allure**: Generación de reportes visuales e interactivos.
106
+
-**Node.js**: Entorno de ejecución.
107
+
108
+
### Estructura del Proyecto
109
+
```
15
110
project-root/
16
111
├── Pages/ # Clases POM para las páginas
17
112
│ └── FormPage.ts # Ejemplo: Clase para interactuar con el formulario
@@ -24,177 +119,57 @@ project-root/
24
119
├── package.json # Dependencias y scripts
25
120
├── tsconfig.json # Configuración de TypeScript
26
121
└── README.md # Este archivo
27
-
Page Object Model (POM)
28
-
Este proyecto usa el patrón POM para encapsular la lógica de interacción con las páginas web:
29
-
Ubicación: Las clases POM están en la carpeta Pages/.
30
-
Ejemplo: FormPage.ts contiene métodos como fillName(), submitForm(), y expectErrorForField() para interactuar con un formulario.
31
-
Ventajas:
32
-
Código reutilizable.
33
-
Separación de lógica de pruebas y elementos de la UI.
34
-
Fácil mantenimiento si la UI cambia.
35
-
Instalación
36
-
Clona el repositorio:
37
-
bash
122
+
```
123
+
124
+
### Instalación
125
+
Clonar el repositorio:
126
+
```bash
38
127
git clone <URL_DEL_REPOSITORIO>
39
128
cd<NOMBRE_DEL_PROYECTO>
40
-
Instala las dependencias:
41
-
bash
129
+
```
130
+
Instalar dependencias:
131
+
```bash
42
132
npm install
43
-
Instala los navegadores de Playwright:
44
-
bash
133
+
```
134
+
Instalar navegadores de Playwright:
135
+
```bash
45
136
npx playwright install
46
-
Requisitos previos
47
-
Node.js: v16 o superior.
48
-
Java: v8 o superior (necesario para Allure CLI).
49
-
Configuración
50
-
El archivo playwright.config.ts define las opciones de ejecución:
51
-
Carpeta de pruebas: ./tests.
52
-
Reporteros: 'line' (consola) y 'allure-playwright' (Allure).
53
-
Navegadores: Chromium por defecto.
54
-
Base URL: https://v0-classic-registration-form-u8ghow.vercel.app/.
"test-and-report": "npm run test && npm run generate-report && npm run open-report"
135
-
}
136
-
}
137
-
Integración con Allure
138
-
Allure se integra como reportero en Playwright para generar reportes detallados:
139
-
Configuración: Definida en playwright.config.ts con 'allure-playwright'.
140
-
Resultados: Guardados en allure-results tras ejecutar las pruebas.
141
-
Generación: Convertidos a HTML con npx allure generate.
142
-
Visualización: Abiertos con npx allure open.
143
-
Ver los reportes
144
-
Después de correr npm run test-and-report, el reporte se abre automáticamente en tu navegador (e.g., http://localhost:XXXX).
145
-
Si no se abre, usa:
146
-
bash
173
+
```bash
147
174
npx allure open allure-report
148
-
El reporte muestra:
149
-
Lista de pruebas con estado (passed, failed, skipped).
150
-
Pasos detallados (test.step).
151
-
Capturas y trazas (si habilitadas).
152
-
Ejemplo de prueba
153
-
typescript
154
-
// tests/registration.spec.ts
155
-
import { test } from '@playwright/test';
156
-
import { FormPage } from '../Pages/FormPage';
157
-
158
-
test.describe('Automation testing on a form', () => {
159
-
let formPage: FormPage;
160
-
161
-
test.beforeEach(async ({ page }) => {
162
-
formPage = new FormPage(page);
163
-
await test.step('Given that I navigate to the web page', async () => {
164
-
await formPage.navigate();
165
-
});
166
-
});
167
-
168
-
test('Empty mandatory fields prevent form submission', async () => {
169
-
await test.step('Given that I do not fill any mandatory fields', async () => {});
170
-
await test.step('When I try to submit the form', async () => {
171
-
await formPage.submitForm();
172
-
});
173
-
await test.step('Then I see errors in the mandatory fields', async () => {
174
-
await formPage.expectErrorForField('El nombre debe tener al menos 2 caracteres.');
175
-
});
176
-
});
177
-
});
178
-
Notas
179
-
POM: Las clases en Pages/ encapsulan localizadores y métodos, haciendo las pruebas más legibles.
180
-
Allure: Requiere Java para npx allure generate. Verifica con java -version.
181
-
TypeScript: Usa tsconfig.json para configurar el compilador:
182
-
json
183
-
{
184
-
"compilerOptions": {
185
-
"target": "es6",
186
-
"module": "commonjs",
187
-
"strict": true,
188
-
"rootDir": "./",
189
-
"outDir": "./dist",
190
-
"esModuleInterop": true
191
-
},
192
-
"include": ["./tests/**/*.ts", "./Pages/**/*.ts"]
193
-
}
194
-
Solución de problemas
195
-
Reporte Allure "unknown":
196
-
Limpia: rm -rf allure-results allure-report.
197
-
Re-ejecuta: npm run test-and-report.
198
-
Pruebas no corren: Verifica localizadores en FormPage.ts con el HTML real.
199
-
Errores de caché: Usa npm run clean y reinstala.
200
-
Este README cubre lo esencial para empezar, ejecutar, y mantener el proyecto. ¿Te gustaría que añada algo más, como ejemplos específicos del formulario o detalles de CI/CD? ¡Avísame!
0 commit comments