Git Product home page Git Product logo

nightwatch-chrome-recorder's Introduction

Nightwatch Chrome Recorder

Build npm Discord

This repo provide tools to convert JSON user flows from Google Chrome DevTools Recorder to Nightwatch test scripts programmatically.

โœ… Converts multiple recordings to Nightwatch tests in one go (out-of-the-box glob support)
๐Ÿ—‚ User can pass their custom path to export tests.
๐Ÿ’ƒ Users can also use a dry run to see the interim output of the recordings
๐Ÿ‘จโ€๐Ÿ’ป Programmatic API which users can use in their own project to create plugins or custom scripts.

Alternatively, you can export JSON user flows as Nightwatch test scripts straight away from Chrome DevTools with our Nightwatch Recorder Chrome extension.

See Create Nightwatch test using Google Chrome DevTools Recorder to learn more.

๐Ÿ“น Demo

Nightwatch Chrome Recorder Demo

๐Ÿ— Installation

npm install -g @nightwatch/chrome-recorder

๐Ÿš€ Usage

To quickly run the interactive CLI, run:

npx @nightwatch/chrome-recorder

The CLI will prompt you to enter the path of directory or file of the chrome devtool recordings that you will modify and path to write the generated Nightwatch tests

โšก๏ธ Transform individual recordings

npx @nightwatch/chrome-recorder <path to the chrome devtools recording>

โšก๏ธ Transform multiple recordings

npx @nightwatch/chrome-recorder <path to the chrome devtools recording>*.json

๐Ÿ‘‰ By default output will be written to nightwatch folder. If you don't have these folders, tool will create it for you or install nightwatch by running npm init nightwatch in your project.

You can specify different output directory, specify that via cli

npx @nightwatch/chrome-recorder <path to the chrome devtools recording> --output=<folder-name>

โš™๏ธ CLI Options

Option Description
-d, --dry Dry run the output of the transformed recordings
-o, --output Output location of the files generated by the exporter

๐Ÿ’ป Programmatic API

import { nightwatchStringifyChromeRecording } from '@nightwatch/chrome-recorder';

const recordingContent = {
  title: 'recording',
  steps: [
    {
      type: 'setViewport',
      width: 1905,
      height: 223,
      deviceScaleFactor: 1,
      isMobile: false,
      hasTouch: false,
      isLandscape: false,
    },
  ],
};

const stringifiedContent = await nightwatchStringifyChromeRecording(
  JSON.stringify(recordingContent),
);

console.log(stringifiedContent);
// Console Log output
//
// describe('recording', function () {
//   it('tests recording', function (browser) {
//     browser.windowRect({ width: 1905, height: 223 });
//   });
// });

๐Ÿ“ Documentation

You can find about more about Programmatic API here

๐Ÿ› Issues

Issues with this schematic can filed here

If you want to contribute (or have contributed in the past), feel free to add yourself to the list of contributors in the package.json before you open a PR!

๐Ÿ‘จโ€๐Ÿ’ป Development

Getting started

๐Ÿ› ๏ธ Node.js and npm are required for the scripts. Make sure it's installed on your machine.

โฌ‡๏ธ Install the dependencies for the nightwatch chrome recorder tool

npm install

๐Ÿ‘ทโ€โ™‚๏ธ Build the tools using typescript compiler

npm run build

๐Ÿƒ Run the tool

./bin/nightwatch-chrome-recorder.js

๐Ÿงช Unit Testing

Run the unit tests using mocha as a runner and test framework

npm run test

โ™ป๏ธ Clean build files

npm run clean

Supported Chrome Devtools Recorder Steps

We only support following steps:

  1. setViewport
  2. navigate
  3. click
  4. change
  5. keyDown
  6. keyUp
  7. scroll
  8. doubleClick
  9. hover
  10. emulateNetworkConditions
  11. waitForElement

If the step type is not mentioned above, a warning will be shown.

nightwatch-chrome-recorder's People

Contributors

jecfish avatar vaibhavsingh97 avatar

Stargazers

 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  avatar  avatar  avatar  avatar  avatar

nightwatch-chrome-recorder's Issues

Add support for text and xpath selector

DevTools Recorder support text and XPath selector from Chrome 108 onwards. I am wondering if there are similar selector in Nightwatch?

Here is the example step's json.

{
      "type": "click",
      "target": "main",
      "selectors": [
        [
          "aria/Proceed to checkout"
        ],
        [
          "[data-test=checkout]"
        ],
        [
          "xpath///*[@data-test=\"checkout\"]"
        ],
        [
          "text/Total: $0.00"
        ]
      ]
    }

Screen Shot 2022-10-16 at 9 35 19 AM

Incorrect browser size open in Chrome

Tried to open a recording with window size 375. When export and replay with nightwatch, Chrome browser did not open the correct size. The window is bigger than 375

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.