All Projects → semrush → purr

semrush / purr

Licence: other
PURR (PUppeteer RunneR) is a devops-friendly tool for browser testing and monitoring.

Programming Languages

javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects
Makefile
30231 projects

Projects that are alternatives of or similar to purr

top.gg-automatic-voter
This is a script that votes for specified bot automatically per 12 hours on top.gg
Stars: ✭ 144 (+289.19%)
Mutual labels:  puppeteer
mugshot
Framework independent visual testing library
Stars: ✭ 126 (+240.54%)
Mutual labels:  puppeteer
pdf
Micro-service for generating PDF files using Puppeteer with an Express API
Stars: ✭ 16 (-56.76%)
Mutual labels:  puppeteer
double-agent
A test suite of common scraper detection techniques. See how detectable your scraper stack is.
Stars: ✭ 123 (+232.43%)
Mutual labels:  puppeteer
abeamer
frame-by-frame Web Animation framework
Stars: ✭ 49 (+32.43%)
Mutual labels:  puppeteer
trafficator
Traffic generator for local analytics testing
Stars: ✭ 27 (-27.03%)
Mutual labels:  puppeteer
codepen-puppeteer
Use Puppeteer to download pens from Codepen.io as single html pages
Stars: ✭ 22 (-40.54%)
Mutual labels:  puppeteer
hardcider
🍺 CLI for quickly generating citations for websites and books
Stars: ✭ 17 (-54.05%)
Mutual labels:  puppeteer
puppeteer-jest-starter
A starter-kit quipped with the minimal requirements for Puppeteer + Jest, making E2E testing a breeze.
Stars: ✭ 17 (-54.05%)
Mutual labels:  puppeteer
readme-ascii
Turns text into images of ASCII art for GitHub README files.
Stars: ✭ 48 (+29.73%)
Mutual labels:  puppeteer
webparsy
Node.JS library and cli for scraping websites using Puppeteer (or not) and YAML definitions
Stars: ✭ 40 (+8.11%)
Mutual labels:  puppeteer
webgif
Easily generate animated GIFs from websites
Stars: ✭ 98 (+164.86%)
Mutual labels:  puppeteer
http-server-pwa
👾 http-server alike but for serving and rendering PWA: pwa-server
Stars: ✭ 14 (-62.16%)
Mutual labels:  puppeteer
ZSpider
基于Electron爬虫程序
Stars: ✭ 37 (+0%)
Mutual labels:  puppeteer
akamai-toolkit
A set of tools to work on Akamai v1 anti-bot solution. Current supported version: 1.70
Stars: ✭ 215 (+481.08%)
Mutual labels:  puppeteer
MagicMouse
A webbrowser for Squeak using Chrome/Chromium. Not to be confused with a highly innovative pointing device.
Stars: ✭ 24 (-35.14%)
Mutual labels:  puppeteer
puppeteer-loadtest
load test puppeteer (Headless Chrome API) script using node
Stars: ✭ 107 (+189.19%)
Mutual labels:  puppeteer
puppeteer-proxy
Proxies Puppeteer Page requests.
Stars: ✭ 172 (+364.86%)
Mutual labels:  puppeteer
simplechrome
Webrecorders DevTools Protocol Automation Library
Stars: ✭ 16 (-56.76%)
Mutual labels:  puppeteer
Puppetry
基于Puppeteer的页面E2E测试GUI工具
Stars: ✭ 35 (-5.41%)
Mutual labels:  puppeteer

PURR

Intro

PURR (PUppeteer RunneR) is a devops-friendly tool for browser testing and monitoring.

The goal of this project is to have single set of browser checks, that could be used as tests, canaries in CI/CD pipelines and scenarios for production monitoring.

The tool uses puppeteer (https://pptr.dev/) to run standalone browsers (Chrome and Firefox are supported currently).

Checks results are stored as JSON reports, screenshots, traces and HAR files.

PURR has three modes:

  • CLI (mainly used in CI/CD pipelines)
  • Queue worker (scheduled monitoring checks)
  • REST service (show results and expose internal metrics for prometheus)

Configuration

data/checks dir

Stores descriptions of every single check

data/suites dir

Organizes checks into suites

data/parameters.yml

Specifies check parameters, i.e. target host or cookie values

data/schedules.yml

Define your schedules here

priority of parameters

  • Defaults from parameters.yml
  • Defaults from check/suite
  • Params from env
  • Explicitly specified params

PURR configuration

You can configure PURR behaviour using environmental variables. Please see the ENV.md for details.

CLI

Build

docker build -f ./docker/Dockerfile . -t puppeteer-runner:latest

Run single check

docker run -v "${PWD}/storage:/src/app/storage" puppeteer-runner:latest ./src/cli/cli.js check semrush-com

Run suite

docker run -v "${PWD}/storage:/src/app/storage" puppeteer-runner:latest ./src/cli/cli.js suite semrush-suite

Results

$ tree storage
storage
├── console_log
│   ├── console_semrush-com_0cedaca3-1153-47df-a616-55e21bf54635.log
│   └── console_semrush-com_ded5990f-7638-48e6-9d0e-77f8dba376fd.log
├── screenshots
│   ├── screenshot_semrush-com_0cedaca3-1153-47df-a616-55e21bf54635.png
│   └── screenshot_semrush-com_ded5990f-7638-48e6-9d0e-77f8dba376fd.png
└── traces
    ├── trace_semrush-com_0cedaca3-1153-47df-a616-55e21bf54635.json
    └── trace_semrush-com_ded5990f-7638-48e6-9d0e-77f8dba376fd.json

Traces and HARs

PURR have a feature to save Chromium traces and HARs.

You can open traces in Chromium Devtools Network Inspector or Chrome DevTools Timeline Viewer. For HAR you can use GSuite Toolbox HAR Analyze.

Scheduled jobs

Run worker

APP_IMAGE_NAME="puppeteer-runner" APP_IMAGE_VERSION="latest" NGINX_IMAGE_NAME="nginx" docker-compose up

Apply schedules

docker-compose exec worker /app/src/cli.js schedule clean
docker-compose exec worker /app/src/cli.js schedule apply

Stop schedules

docker-compose exec worker /app/src/cli.js schedule clean

REST API

Endpoints

GET /metrics

Prometheus metrics

GET /api/v1/checks

List of existing checks

query strings

POST /api/v1/checks/:name

Add check to queue

Response

200: Returns check report 202: Returns id of created check job

Payload
  • name: string Check name to run
  • params: array Any check parameter
Query strings
  • wait: bool default: false Just return link for report when false
  • view: string default: json options: json, pretty Output format
Example:
curl -X POST \
  -d 'params[TARGET_SCHEMA]=http' \
  -d 'params[TARGET_DOMAIN]=rc.example.com' \
  http://purr.traefik.lcl/api/v1/checks/main-page?wait=true&view=pretty

GET /api/v1/reports/:id

Get report

Payload
  • id: string Check report id
Query strings
  • view: string default: json options: json, pretty Output format

Writing checks

PURR translates scenario steps described in ./data/checks into methods of puppeteer.Page object. You can check puppeteer reference documentation for up-to-date capabilities.

Methods

List of methods which were tested by the PURR dev team

- goto:
    - '{{ TARGET_SCHEMA }}://{{ TARGET_DOMAIN }}/{{ TARGET_PAGE }}/'

- goto:
    - '{{ TARGET_SCHEMA }}://{{ TARGET_DOMAIN }}/{{ TARGET_PAGE }}/'
    - waitUntil: networkidle2

- waitForNavigation:
    - waitUntil: domcontentloaded

- click:
    - '{{ CSS_OR_DOM_SELECTOR }}'

- type:
    - '{{ CSS_OR_DOM_SELECTOR }}'
    - '{{ STRING_TO_TYPE }}'

- waitForSelector:
    - '{{ CSS_OR_DOM_SELECTOR }}'

- setCookie:
    - name: '{{ COOKIE_NAME }}'
      value: '{{ COOKIE_VALUE }}'
      domain: .{{ TARGET_DOMAIN.split('.').slice(-2).join('.') }}

Custom Methods

Custom steps methods are described in src/actions dir and can be executed in checks.

- actions.common.selectorContains:
    - '[data-test="user-profile"]'
    - 'User Name:'

Includes

Feel free to use YAML anchors in your scenarios

.login_via_popup: &login_via_popup
  - click:
    - '[data-test="login"]'
  - waitForSelector:
    - '[data-test="email"]'
  - type:
    - '[data-test="email"]'
    - '{{ USER_EMAIL }}'
  - type:
    - '[data-test="password"]'
    - '{{ USER_PASSWORD }}'
  - click:
    - '[data-test="login-submit"]'


logged-user-dashboard:
  parameters:
    USER_PASSWORD: secret
  steps:
    - goto:
      - '{{ TARGET_URL }}'
      - waitUntil: networkidle2
    <<: *login_via_popup
      parameters:
        USER_EMAIL: root@localhost
    - waitForSelector:
      - '[data-test="user-profile"]'
    - actions.common.selectorContains:
      - '[data-test="user-profile"]'
      - 'User Name:'

Variables

You can specify parameters in checks and suites yaml files under 'parameters' key

parameters:
  TARGET_HOST: localhost

valid-password:
  <<: *login_via_popup
  parameters:
    USER_EMAIL: root@localhost
    USER_PASSOWRD: secret

invalid-password:
  <<: *login_via_popup
  parameters:
    USER_PASSOWRD: invalid

Proxy

To run a check, suite or schedule throw proxy use 'proxy' key

check-page-from-india:
  proxy: 'socks5h://user:[email protected]:8080'
  steps:
    - goto:
        - '{{ TARGET_URL }}'
    - waitForSelector:
        - body
    - actions.common.selectorContains:
        - body
        - 'Your location: India'

Development

IMPORTANT: It's expected that for convenient experience you will use vscode as an IDE with recommended extensions(configs are available in this repository).

make start-dev
make attach-dev

Tests

Run tests:

yarn run test

Mocks

We are using Jest testing framework.

You can mock module like that:

// If `manual` mock exist in dir `__mocks__` along module file, will be used
// automatically.
//
// Mocked module methods return `undefined`, fields return actual value.
jest.mock('../../config');
// Now `config` for all scripts will be `{ concurrency: 9 }`
jest.mock('../../config', () => ({ concurrency: 9 }));

Or like that:

const config = require('../../config');

config.concurrency = 1;
config.getWorkingPath = jest.fn().mockImplementation(() => {
  return '/working/path';
});
Be careful

Methods mock\unmock must be executed before module imports and in the same scope. Mocks state restoring after each test, but only when you did not used jest.mock()

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].