Giter Site home page Giter Site logo

sserbu13 / playwright-java-test-automation-architecture Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tahanima/playwright-java-test-automation-architecture

0.0 0.0 0.0 1.74 MB

Ready-to-use UI Test Automation Architecture using Java and Playwright.

Home Page: https://tahanima.github.io/playwright-java-test-automation-architecture/

License: MIT License

Java 100.00%

playwright-java-test-automation-architecture's Introduction

Playwright Java Test Automation Architecture

Ready-to-use UI Test Automation Architecture using Java and Playwright.

Installation Steps

In order to use the framework:

  1. Fork the repository.
  2. Clone, i.e, download your copy of the repository to your local machine using
git clone https://github.com/[your_username]/playwright-java-test-automation-architecture.git
  1. Import the project in IntelliJ IDEA.
  2. Make your desired changes.
  3. Use IntelliJ IDEA to run your desired tests. Alternatively, you can use the terminal to run the tests, for example ./gradlew test -Dbrowser=firefox -Dheadless=false to run all the tests using the firefox browser in headed mode.
  4. Build and browse the allure report using
./gradlew allureServe

Languages and Frameworks

The project uses the following:

Project Structure

The project is structured as follows:

📦 playwright-java-test-automation-architecture
├─ .github
│  ├─ FUNDING.yml
│  ├─ dependabot.yml
│  └─ workflows
│     └─ test-execution.yml
├─ .gitignore
├─ LICENSE
├─ README.md
├─ build.gradle
├─ gradle
│  └─ wrapper
│     ├─ gradle-wrapper.jar
│     └─ gradle-wrapper.properties
├─ gradlew
├─ gradlew.bat
├─ settings.gradle
└─ src
   ├─ main
   │  └─ java
   │     └─ io
   │        └─ github
   │           └─ tahanima
   │              ├─ config
   │              │  ├─ Configuration.java
   │              │  └─ ConfigurationManager.java
   │              ├─ dto
   │              │  ├─ BaseDto.java
   │              │  ├─ LoginDto.java
   │              │  └─ ProductsDto.java
   │              ├─ factory
   │              │  ├─ BasePageFactory.java
   │              │  └─ BrowserFactory.java
   │              ├─ ui
   │              │  ├─ component
   │              │  │  ├─ BaseComponent.java
   │              │  │  ├─ Header.java
   │              │  │  └─ SideNavMenu.java
   │              │  └─ page
   │              │     ├─ BasePage.java
   │              │     ├─ LoginPage.java
   │              │     └─ ProductsPage.java
   │              └─ util
   │                 └─ BrowserManager.java
   └─ test
      ├─ java
      │  └─ io
      │     └─ github
      │        └─ tahanima
      │           ├─ annotation
      │           │  ├─ DataSource.java
      │           │  ├─ Regression.java
      │           │  ├─ Smoke.java
      │           │  └─ Validation.java
      │           ├─ e2e
      │           │  ├─ BaseTest.java
      │           │  ├─ LoginTest.java
      │           │  └─ ProductsTest.java
      │           └─ util
      │              ├─ CsvToDtoMapper.java
      │              └─ DataArgumentsProvider.java
      └─ resources
         ├─ allure.properties
         ├─ config.properties
         ├─ junit-platform.properties
         └─ testdata
            ├─ login.csv
            └─ products.csv

Basic Usage

  • Configuration

    The project uses a config.properties file to manage global configurations such as browser type and base url.

    1. To add a new property, register a new entry in this file.

      key=value
      

      Then, add a method in the Configuration interface in the below format.

      @Key("key")
      dataType key();

      For example, let's say I want to add a new property named context with the value dev. In the config.properties file, I'll add:

      context=dev
      

      In the Configuration interface, I'll add:

      @Key("context")
      String context();

      To use your newly created property, you need to use the below import statement.

      import static io.github.tahanima.config.ConfigurationManager.config;

      Then, you can call config().key() to retrieve the value of your newly created property. For the example I've provided, I need to call config().context().

    2. You can supply the properties present in the config.properties file as system properties in your test via gradle.

      ./gradlew test -Dkey1=value1 -Dkey2=value2
  • Test Data

    The project uses csv file to store test data and univocity-parsers to retrieve the data and map it to a Java bean.

    To add configurations for new test data, add a new Java bean in the dto package. For example, let's say I want to add test data for a User with the attributes First Name and Last Name. The code for this is as follows:

    package io.github.tahanima.dto;
    
    import com.univocity.parsers.annotations.Parsed;
    
    import lombok.Getter;
    import lombok.ToString;
    
    @Getter
    @ToString(callSuper = true)
    public class UserDto extends BaseDto {
    
        @Parsed(field = "First Name", defaultNullRead = "")
        private String firstName;
    
        @Parsed(field = "Last Name", defaultNullRead = "")
        private String lastName;
    }

    Note that the class extends from BaseDto and thus, inherits the attribute Test Case ID.

    Now, in the testdata folder you can add a csv file user.csv for User with the below contents and use it in your tests.

    Test Case ID,First Name,Last Name
    TC-1,Tahanima,Chowdhury
    

    For reference, check this, this and this.

  • Page Objects and Page Component Objects

    The project uses Page Objects and Page Component Objects to capture the relevant behaviors of a web page. Check the ui package for reference.

  • Tests

    The project uses JUnit 5 as the test runner. Check this implementation for reference.

playwright-java-test-automation-architecture's People

Contributors

ajeans avatar dependabot[bot] avatar tahanima avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.