Giter VIP home page Giter VIP logo

playwright-cucumber's Introduction

Playwright Test Execution

Playwright (execution on Moon) with CucumberJS

Playwright end-to-end test automation with CucumberJS

Getting Started

  • To install Playwright : npm install playwright --save-dev
  • To install Cucumber : npm install cucumber --save-dev
  • To install Junit Reporter : npm install cucumberjs-junitxml --save-dev
  • To install Chai : npm install chai --save-dev

To execute the tests

Define the scripts in package.json as follows :

"scripts": {
    "test": "cucumber-js --parallel 1 -f json:report/report.json && node report.js && cat report/report.json | npx cucumber-junit > report/junitreport.xml"
  }

Finally execute the tests with npm test

Create a global browser for the test session

BeforeAll(async() =>{
        if (moonHost){
                global.browser = await chromium.connect({
                timeout: 0,
                wsEndpoint: 'ws://'+moonHost+':4444/playwright/chromium'
            });
        }
        else{
            global.browser = await chromium.launch();
        }
});

Create a fresh browser context for each test

Before(async() =>{
    global.context = await global.browser.newContext();
    global.page = await global.context.newPage();
});

A sample Feature file

Scenario Outline: Login to the E-Shop Application with Wrong Password
    Given User launched eshop login page
    When User logged in eshop using the invalid emailid "<EmailID>" and the invalid password "<Password>"
    Then User should not get logged in

    Examples:
      | EmailID                    | Password  |
      | testuser_negative@shop.com | Testing$1 |

A sample stepdefinition

When('User logged in eshop using the invalid emailid {string} and the invalid password {string}',async(username,password) =>{
    await loginpage.login(username,password);
});

Example of how a Playwright code snippet looks

const { firefox } = require('playwright');

(async () => {
  const browser = await firefox.launch();
  const context = await browser.newContext();
  const page = await context.newPage();
  await page.goto('https://www.example.com/');
  await page.screenshot({ path: 'page.png', fullPage: true });

  await browser.close();
})();

For more on Playwright click here

To know about Moon, how to deploy and use Moon, read the article below : https://ghoshasish99.medium.com/deploy-moon-on-azure-and-google-cloud-607a9604bccc

playwright-cucumber's People

Contributors

ghoshasish99 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

playwright-cucumber's Issues

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.