Code Monkey home page Code Monkey logo

pw-factory-project's Introduction

Welcome to the Factory Pattern Automation Project

This project implements the Factory Design Pattern in order to automate web testing using Playwright. The main aim of this project is to make it easier for users to perform automated tests on web applications using Playwright by providing a structured way to define and perform actions on pages.

Features

  • Easy integration with Playwright
  • Ability to define tests in a declarative manner using JSON
  • Implementation of the Factory Design Pattern for page objects

Run Locally

Clone the project

  git clone https://github.com/<repo-name>.git

Go to the project directory

  cd my-project

Install dependencies

  npm install

Start the test

  npm run test

Folder Structure

src
├── pages
│   ├── abstract.page.ts
│   └── pages.ts
├── tests
│   └── test.spec.ts
└── utils
    └── common
        ├── actions
        │   └── actions.map.ts
        ├── fixtures
        │   └── fixture.config.ts
        └── FormInteractions
            └── FormInteractions.page.ts

Code Structure

The project consists of several classes, each of which serves a specific purpose. The key classes are:

FormInteractions: This class performs the actual actions (e.g. fill, click) on the page using Playwright. BasePage: This class implements the base page and includes the visit and performActions methods, which are called when visiting the page and performing the defined actions respectively. LoginPage: This class extends the BasePage class and is used to define the Login page of the application. MainPage: This class extends the BasePage class and is used to define the Main page of the application.

Page Configuration

A JSON configuration object is used to define the actions that should be performed on each page. The configuration object consists of the URL of the page and an array of actions. Each action consists of a locator, an action type (e.g. fill, click), and a value.

LOGIN_PAGE: {
    URL: 'https://www.saucedemo.com/',
    ACTIONS: [
      {
        LOCATOR: '#user-name',
        ACTION: 'fill',
        VALUE: 'standard_user',
      },
      {
        LOCATOR: '#password',
        ACTION: 'fill',
        VALUE: 'secret_sauce',
      },
      {
        LOCATOR: '#login-button',
        ACTION: 'click',
        VALUE: null,
      },
    ],
  },

Conclusion

By using the Factory Design Pattern in combination with JSON configuration, this project provides a flexible and structured approach for automating web testing using Playwright. It makes it easier for users to write tests by providing a clear and concise way to define actions on pages.

pw-factory-project's People

Contributors

grealishcalves avatar

Watchers

 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.