Modern Cross Browser Testing in JavaScript using Playwright

Overview

Modern Cross Browser Testing in JavaScript using Playwright

Modern Cross Browser Testing in JavaScript using Playwright

This repository contains the example code for the Modern Cross Browser Testing in JavaScript using Playwright workshop led by Pandy Knight and hosted by Applitools.

Full instructions for the workshop are provided in WORKSHOP.md.

Abstract

Testing web apps in 2022 is hard. Not only are apps more complex than ever, but their pages must also be validated against an exploding number of combinations of browsers, devices, and versions – an industry average of 81,480 screens to 681,296 for the top 33%.

Testing tools are also changing. While browser automation tools like Selenium WebDriver and cross-browser testing architectures like Selenium Grid have been industry mainstays for years, new tools are emerging that offer faster, more reliable automation with richer features.

In this 1-hour workshop, “Automation Panda” Andy Knight will explain how to automate cross-browser tests in JavaScript using Playwright, a relatively new open-source, end-to-end test framework from Microsoft, and how to integrate them into CI/CD to provide feedback on quality across all browser/device combinations in seconds.

Highlights:

  • The importance and evolution of cross-browser testing
  • Critical requirements for a scalable cross-browser testing initiative and pros/cons of different approaches
  • How to accelerate cross-browser and cross-device testing for integration into CI/CD using JavaScript with Playwright

Outline

  1. Traditional cross-browser testing
    1. Writing a typical login test
    2. Running the test locally
    3. Running the test against multiple browsers
    4. Scaling out cross-browser testing yourself
    5. Scaling out cross-browser testing as a service
  2. Modern cross-browser testing
    1. Reconsidering what should be tested
    2. Introducing Applitools Ultrafast Grid
    3. Rewriting login as a visual test
    4. Running visual tests across multiple browsers
    5. Integrating modern cross-browser testing with CI/CD

Prerequisites

To complete this workshop, you will need:

  1. An Applitools account
    • Register here for a free account
  2. Node.js
    • This project was created with v16.13.1
  3. Visual Studio Code

Architecture

This project is a small JavaScript test automation project containing Playwright test cases for an Applitools demo site. Each test case covers the same login behavior, but they do so in different ways:

  1. traditional.spec.js covers login using traditional assertions on a local machine.
  2. visual.spec.js covers login using Visual AI with Applitools Eyes and Ultrafast Grid.

Running tests

You'll need to run a few commands to run tests:

  • To install project dependencies, run npm install.
  • To install browser projects, run npx playwright install.
  • To launch all tests, run npx playwright test.

Before running the visual test, you must set the APPLITOOLS_API_KEY OS environment variable to your Applitools API key so that the test can connect to the Applitools cloud.

There are also two versions of the demo site under test:

  1. The original version of the site
  2. A changed version of the site with visual differences

To control which version to test, set the DEMO_SITE environment variable to original or changed.

This project also provides a number of npm scripts to make launch commands simpler:

  • npm test - runs all tests using all browser projects
  • npm run traditional - runs the traditional test using all browser projects
  • npm run traditional:original - runs the traditional test against the original site using all browser projects
  • npm run traditional:changed - runs the traditional test against the changed site using all browser projects
  • npm run visual - runs the visual test using Chromium locally
  • npm run visual:original - runs the visual test against the original site using Chromium locally
  • npm run visual:changed - runs the visual test against the changed site using Chromium locally

You can also append any Playwright command line options to these npm commands by adding them after --.

You might also like...

Nuxt3 template with Windicss + Pinia + Vitest + Playwright

Nuxt3 template with Windicss + Pinia + Vitest + Playwright

Nuxt 3 Template Nuxt 3 template repository Look at the nuxt 3 documentation to learn more. Used Technologies Usage Setup Make sure to install the depe

Dec 14, 2022

🤖 Persist the Playwright executable between Netlify builds

🤖 Persist the Playwright executable between Netlify builds

🤖 Netlify Plugin Playwright Cache Persist the Playwright executables between Netlify builds. Why netlify-plugin-playwright-cache When you install pla

Oct 24, 2022

AREX: It is a “Differential Testing” and “Record and Replay Testing” Tool.

AREX: It is a “Differential Testing” and “Record and Replay Testing” Tool. Test restful API by record, replay and stub request/response. Differential

Nov 1, 2022

A lightweight cross browser javascript scrollbar.

tinyscrollbar ** HELP MAINTAINER NEEDED!! ** Environments in which to use tinyscrollbar Browser support differs between the jQuery plugin and the plai

Nov 9, 2022

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API

screenfull Simple wrapper for cross-browser usage of the JavaScript Fullscreen API, which lets you bring the page or any element into fullscreen. Smoo

Dec 30, 2022

🔨 Cross-browser JavaScript library to disable scrolling page

🔨 Cross-browser JavaScript library to disable scrolling page

scroll-lock Cross-browser JavaScript library to disable scrolling page Live demo | README на русском New features 2.0 More advanced touch event handli

Dec 17, 2022

To-do list is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark them as complete. It is tested by JavaScript Unit testing using Jest framework. It is build by using ES6 and Webpack!

Project Name To Do list: interactive list Description the project. In this project, I added some functionality to my application to make it interactiv

Nov 11, 2022

dotdotdot.js, advanced cross-browser ellipsis for multiple line content.

dotdotdot.js, advanced cross-browser ellipsis for multiple line content.

dotdotdot Dotdotdot is a javascript plugin for truncating multiple line content on a webpage. It uses an ellipsis to indicate that there is more text

Dec 20, 2022

🦎 The cross browser extension that blends in

🦎 The cross browser extension that blends in

Rango Rango is a cross browser extension that helps you interact with web pages using your voice and talon. It does this by drawing hints with letters

Jan 3, 2023
Owner
Applitools
Automating visual software testing
Applitools
Automagically bypass hcaptcha challenges with http api, with puppeteer, selenium, playwright browser automation scripts to bypass hCaptcha programmatically

Automagically bypass hcaptcha challenges with http api, with puppeteer, selenium, playwright browser automation scripts to bypass hCaptcha programmatically. For help you can message on discord server with the bellow link. You can also create an issue.

Shimul 199 Jan 2, 2023
Javascript-testing-practical-approach-2021-course-v3 - Javascript Testing, a Practical Approach (v3)

Javascript Testing, a Practical Approach Description This is the reference repository with all the contents and the examples of the "Javascript Testin

Stefano Magni 2 Nov 14, 2022
Scrape tweets from Twitter search results based on keywords and date range using Playwright. Save scraped tweets in a CSV file for easy analysis

Tweet Harvest (Twitter Crawler) Tweet Harvest is a command-line tool that uses Playwright to scrape tweets from Twitter search results based on specif

Helmi Satria 33 Aug 9, 2023
Functions for testing the types of JavaScript values, cross-realm. Has testers for all standard built-in objects/values.

@suchipi/is Functions for testing the types of JavaScript values, cross-realm. Has testers for all standard built-in objects/values. Usage import { is

Lily Skye 5 Sep 8, 2022
Diferentes demos em relação ao uso do Playwright para realização de palestras sobre o assunto

?? Playwright [Demos] - Palestra: Testes Inteligentes, Automatizados e Rápidos em Cross-Browser com Playwright! Repositório responsável pelas demos re

Glaucia Lemos 47 Oct 20, 2022
Google-reviews-crawler - A simple Playwright crawler that stores Google Maps Place/Business reviews to a JSON file.

google-reviews-crawler A simple Playwright crawler that stores Google Maps Place/Business reviews to a JSON file. Usage Clone the repo, install the de

￸A￸l￸e￸x D￸o￸m￸a￸k￸i￸d￸i￸s 6 Oct 26, 2022
Command line tool that automatically migrates tests from protractor to playwright.

Protractor to Playwright migration tool This tool is designed to automatically migrate code from Protractor to Playwright. It is inspired by the "Migr

Amadeus IT Group 9 Nov 20, 2022
🚀 Macaca Playwright driver

macaca-playwright Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API. Macaca P

Macaca 13 Nov 8, 2022
Remix + Cloudflare Workers + Wrangler2 + Tailwind + ESLint + Prettier + Vitest + Playwright

Welcome to Remix! Remix Docs Development You will be running two processes during development: The Miniflare server (miniflare is a local environment

null 48 Dec 19, 2022
Sample project to demonstrate Playwright Test usage, pointing to ServeRest API and Front-end

demo-playwright-test This is a sample project to demonstrate Playwright Test usage, running tests against ServeRest API and Front-end. Pre-requisites

Stefan Teixeira 30 Oct 24, 2022