Code Monkey home page Code Monkey logo

virtual-cursor's Introduction

virtual-cursor

license MIT Python Version Latest Version

virtual-cursor adds human-like cursor animations to your browser tests.

Browser test libraries like Selenium or Playwright can be used to generate screenshots or videos of websites, which are great for debugging or as media for documentation. Most of the times, these videos are not very useful, because the test code clicks much faster than a human and the cursor is invisible.

virtual-cursor emulates a cursor by injecting a custom JavaScript payload into the test browser, which animates a mocked, second cursor, and adds delays to slow down the test code.

Gallery

Installation

virtual-cursor can be installed via pip

pip install virtual-cursor

Usage

pytest + playwright

See a full example which produces the clip above.

async def test_virtual_cursor():
    from playwright.async_api import async_playwright

    from virtual_cursor.playwright import click, fill, check, selectOption

    async with async_playwright() as playwright:
        browser = await playwright.chromium.launch()

        browser_context = await browser.new_context(
            record_video_dir='/tmp/videos/',
        )

        page = await browser_context.new_page()
        await page.goto('http://localhost')

        # click element
        await click(page, '#button')

        # fill out a text-input
        await fill(page, '#text-input', 'Lorem Ipsum')

        # select an option of a select
        await selectOption(page, '#select', 'Option 17')

        # check a checkbox
        await check(page, '#check-box')

virtual-cursor's People

Contributors

fscherf avatar

Stargazers

Dennis Schwertel avatar Thomas M. Schöller avatar

Watchers

 avatar  avatar

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.