English documentation is here.
Este projeto é uma estrutura de automação de testes utilizando Playwright com Java e Cucumber. Ele é projetado para realizar testes de interface do usuário em aplicações web, seguindo os princípios do Behavior-Driven Development (BDD).
O projeto segue uma arquitetura em camadas, típica de projetos de automação de testes:
- Camada de Especificação (Gherkin): Contém os arquivos .feature com os cenários de teste escritos em linguagem Gherkin.
- Camada de Steps: Implementa os passos definidos nos arquivos .feature.
- Camada de Interações: Contém a lógica de interação com a página web.
- Camada de Pages: Define os elementos da página e seus localizadores.
- Camada de Configuração: Gerencia as configurações do projeto e do ambiente de teste.
├── src/
│ └── test/
│ ├── java/
│ │ └── br/
│ │ └── com/
│ │ └── playwright/
│ │ ├── features/
│ │ ├── pages/
│ │ ├── steps/
│ │ └── interactions/
│ │
│ └── resources/
│ └── testconfigs.properties
│
├── pom.xml
├── README.md
├── mvnw
└── mvnw.cmd
Contém os arquivos .feature escritos em Gherkin. Exemplo:
File: src\test\java\br\com\playwright\features\ExampleFeature.feature
#language: pt
Funcionalidade: Example Funcionalidade
// redacted
Cenário: Validar PDP
Quando pesquiso por "Quadro Decorativo para Camiseta de Futebol"
Então vejo a lista de resultados
Quando clico no resultado com texto "Quadro Decorativo para Camiseta de Futebol, Esportes Preto"
Então vejo a página do produtoImplementa os passos definidos nos arquivos .feature. Exemplo:
File: src\test\java\br\com\playwright\steps\ExampleSteps.java
@Então("vejo a página do produto")
public void vejoAPaginaDoProduto() {
exampleInteractions.validarPaginaDoProduto();
}Define os elementos da página e seus localizadores. Exemplo:
File: C:/Users/kesle/AquaProjects/rennerJavaPlaywrightPoc/src/test/java/br/com/playwright/pages/ExamplePage.java
package br.com.playwright.pages;
public class ExamplePage {
public String searchInput = "#automation-search-icon-template-input-id";
public String searchButton = "#automation-search-icon-template-input-id";
public String resultsList = "#js-productCardContainer";
public String productCardsList = "product-card-square-listing";
public String productTitlePdp = "div.desktop-layout div.product-name h1";
public String productPricePdp = "div.desktop-layout text-label.price div.label";
}classDiagram
class ExampleFeature
class ExampleSteps
class ExampleInteractions
class ExamplePage
class TestRunner
ExampleFeature ..> ExampleSteps : uses
ExampleSteps --> ExampleInteractions : uses
ExampleInteractions --> ExamplePage : uses
TestRunner ..> ExampleFeature : runs
class ExampleFeature {
+Cenário: Validar PDP()
}
class ExampleSteps {
+vejoAPaginaDoProduto()
}
class ExampleInteractions {
+validarPaginaDoProduto()
}
class ExamplePage {
+String searchInput
+String searchButton
+String resultsList
+String productCardsList
+String productTitlePdp
+String productPricePdp
}
class TestRunner {
+main()
}
Esta estrutura de projeto permite uma separação clara de responsabilidades, facilitando a manutenção e expansão dos testes. A combinação de Playwright com Cucumber permite a criação de testes robustos e legíveis, enquanto a organização em camadas promove a reutilização de código e a clareza na implementação dos testes.
Certainly! I'll recreate the documentation in English, detailing the architecture, folder structure, and including a conceptual class diagram.
This project is a test automation framework using Playwright with Java and Cucumber. It is designed to perform user interface tests on web applications, following the principles of Behavior-Driven Development (BDD).
The project follows a layered architecture, typical of test automation projects:
- Specification Layer (Gherkin): Contains .feature files with test scenarios written in Gherkin language.
- Steps Layer: Implements the steps defined in the .feature files.
- Interactions Layer: Contains the logic for interacting with the web page.
- Pages Layer: Defines the page elements and their locators.
- Configuration Layer: Manages project and test environment configurations.
├── src/
│ └── test/
│ ├── java/
│ │ └── br/
│ │ └── com/
│ │ └── playwright/
│ │ ├── features/
│ │ ├── pages/
│ │ ├── steps/
│ │ └── interactions/
│ │
│ └── resources/
│ └── testconfigs.properties
│
├── pom.xml
├── README.md
├── mvnw
└── mvnw.cmd
Contains .feature files written in Gherkin. Example:
File: src\test\java\br\com\playwright\features\ExampleFeature.feature
#language: pt
Feature: Example Feature
// redacted
Scenario: Validate PDP
When I search for "Decorative Frame for Football T-shirt"
Then I see the list of results
When I click on the result with text "Decorative Frame for Football T-shirt, Black Sports"
Then I see the product pageImplements the steps defined in the .feature files. Example:
File: src\test\java\br\com\playwright\steps\ExampleSteps.java
@Then("I see the product page")
public void iSeeTheProductPage() {
exampleInteractions.validateProductPage();
}Defines the page elements and their locators. Example:
File: C:/Users/kesle/AquaProjects/rennerJavaPlaywrightPoc/src/test/java/br/com/playwright/pages/ExamplePage.java
package br.com.playwright.pages;
public class ExamplePage {
public String searchInput = "#automation-search-icon-template-input-id";
public String searchButton = "#automation-search-icon-template-input-id";
public String resultsList = "#js-productCardContainer";
public String productCardsList = "product-card-square-listing";
public String productTitlePdp = "div.desktop-layout div.product-name h1";
public String productPricePdp = "div.desktop-layout text-label.price div.label";
}classDiagram
class ExampleFeature
class ExampleSteps
class ExampleInteractions
class ExamplePage
class TestRunner
ExampleFeature ..> ExampleSteps : uses
ExampleSteps --> ExampleInteractions : uses
ExampleInteractions --> ExamplePage : uses
TestRunner ..> ExampleFeature : runs
class ExampleFeature {
+Scenario: Validate PDP()
}
class ExampleSteps {
+iSeeTheProductPage()
}
class ExampleInteractions {
+validateProductPage()
}
class ExamplePage {
+String searchInput
+String searchButton
+String resultsList
+String productCardsList
+String productTitlePdp
+String productPricePdp
}
class TestRunner {
+main()
}
This project structure allows for a clear separation of responsibilities, facilitating the maintenance and expansion of tests. The combination of Playwright with Cucumber enables the creation of robust and readable tests, while the layered organization promotes code reuse and clarity in test implementation.
The framework is designed to be scalable and maintainable, with each layer having a specific responsibility:
- The Gherkin features provide a high-level, business-readable description of the tests.
- The Steps layer translates these descriptions into executable code.
- The Interactions layer contains the logic for interacting with web elements.
- The Pages layer defines the structure and elements of each web page being tested.
This separation allows for easy updates when the application under test changes, as well as the ability to reuse components across different test scenarios. The use of Playwright provides powerful browser automation capabilities, while Cucumber enables a BDD approach that can improve communication between technical and non-technical team members.