Skip to main content

Write responsive web apps in full python

Project description

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')

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

virtual-cursor-0.1.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

virtual_cursor-0.1-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page