Coder Social home page Coder Social logo

vinaykumarbm / playwright-cucumber-sample Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 3.0 174 KB

This is a sample test automation framework developed using Playwright with Cucumber

Shell 0.77% JavaScript 0.97% Gherkin 8.48% TypeScript 89.78%
api-testing api-testing-framework bdd-framework cucumber-js cucumber-playwright cucumberjs javascript playwright playwright-typescript restful-webservices

playwright-cucumber-sample's Introduction

Test Execution

playwright-cucumber-sample

Overview:

This is a sample test automation framework developed using Playwright with Cucumber.

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.

Cucumber is a tool for running automated tests written in plain language. Because they're written in plain language, they can be read by anyone on your team. Because they can be read by anyone, you can use them to help improve communication, collaboration and trust on your team. Cucumber supports behavior-driven development. Central to the Cucumber BDD approach is its ordinary language parser called Gherkin.

For Demo purpose web UI test cases are created on ecommerce-playground.lambdatest.io site and API test cases are created on these SOAP Calculator API & REST Library Information System API endpoints.

Features

  • This testing framework supports Behavior Driven Development (BDD). Tests are written in plain English text called Gherkin
  • Framework has built in library to operate on UI, API (both SOAP & REST API) and DB (MSSQL, DB2 & Oracle).
  • Supports execution of tests in different browsers.
  • Supports running scenarios in parallel mode. It runs 2 scenarios in parallel by default.
  • Flaky scenario can be Retried multiple times until either it passes or the maximum number of attempts is reached. You can enable this via the retry configuration option.
  • Supports rerun of the failed scenarios.
  • Scenarios can be easily skipped by adding @ignore tag to scenarios
  • Supports dry run of scenarios this helps to identifies the undefined and ambiguous steps.
  • Has utility built in for file download, Read PDF files etc.
  • Generates Cucumber HTML Report & HTML Report.
  • HTML reports are included with snapshots and video in case of failed scenarios.
  • Test execution logs are captured in the log file.
  • All the configuration are controlled by .env file and environment variables can be modified at runtime.
  • Easy and simple integration to CI/CD tools like Jenkins.

Supported Browsers

  1. Chrome - default browser
  2. Firefox
  3. MS Edge
  4. WebKit - web browser engine used by Safari

Steps to use

1. Installation

Playwright framework requires Node.js v14+ to run.

Code from github need to be download OR cloned using git command.

Installing the dependencies.

npm ci
2. Test creation
  • Test scenarios are organized into features and these feature files should be placed inside features folder.
  • Step definitions connect Gherkin steps in feature files to programming code. A step definition carries out the action that should be performed by the scenario steps. These step definitions should placed inside steps folder in different packages.
  • For web UI based tests maintain all the selectors inside pages folder.
3. Execution

To run test scenarios use below command.

npm run test

To run specific scenario, use tags command. Below are few examples.

npm run test:tags @sanity
npm run test:tags "@calculator or @author"
npm run test:tags "@rest and @author"

To dry run test scenarios use below command.

npm run dry:test

To rerun the failed test scenarios use below command.

npm run failed:test

To change any environment configuration in .env file at run time use set command. Eg: To change browser to Firefox use below command

set BROWSER=firefox

Similar command can be used to update other environment configuration

To generate HTML and Cucumber report use below command

npm run report
4. Report & Logs

Cucumber HTML report will be present inside

test-results/reports/cucumber.html

HTML report will be present inside

test-results/reports/html/index.html

Execution log will be present in the log file.

test-results/logs/execution.log

Before you Go

๐Ÿ“ If you find my work interesting don't forget to give a Star โญ & Follow me ๐Ÿ‘ฅ

playwright-cucumber-sample's People

Contributors

vinaykumarbm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

playwright-cucumber-sample's Issues

error in execution

When trying to execute its giving error as below. is something i am missing?
npm run test:tags @validSearch

npx cucumber-js -p runner --tags

error: option '-t, --tags ' argument missing
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:tags: npx cucumber-js -p runner --tags
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:tags script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

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.