pytest-vnc: capture screen and send keyboard & mouse
pytest-vnc implements a VNC client in pure Python. It works on Mac, Linux and Windows. Use the vnc fixture to capture screenshots and send keyboard & mouse from your pytest tests:
from pytest_vnc import Rect, Point
def test_thing(vnc):
# Screenshot
print(vnc.rect.width, vnc.rect.height)
pixels = vnc.capture() # rgba numpy array of entire screen
pixels = vnc.capture(Rect(x=100, y=0, width=50, height=75))
# to use PIL/pillow:
# image = Image.fromarray(pixels)
# Keyboard input
vnc.write('hi there!') # keys are queued
vnc.press('Ctrl', 'c') # keys are stacked
with vnc.hold('Ctrl'):
vnc.press('Esc')
# Mouse input
vnc.move(Point(100, 200))
vnc.click()
vnc.double_click()
vnc.middle_click()
vnc.right_click()
vnc.scroll_up()
vnc.scroll_down(repeat=10)
with vnc.drag():
vnc.move(Point(300, 400))
with vnc.middle_drag():
vnc.move(Point(500, 600))
with vnc.right_drag():
vnc.move(Point(700, 800))
Installation
This package requires Python 3.7+.
Install pytest-vnc by running:
pip install pytest-vnc
Configuration
The following configuration options can be set in pytest.ini:
- vnc_host
VNC hostname (default: localhost)
- vnc_port
VNC port (default: 5900)
- vnc_speed
VNC interactions per second (default: 20)
- vnc_timeout
VNC connection timeout in seconds (default: 5)
- vnc_pixel_format
VNC colour channel order (default: rgba)
- vnc_user
VNC username (default: env var: PYTEST_VNC_USER or current user)
- vnc_passwd
VNC password (default: env var: PYTEST_VNC_PASSWD)
The following attributes can be set on the vnc object:
- speed
Interactions per second (default: 20)
- sleep
Callable that accepts a duration in seconds and waits for that long (default: time.sleep())
Metadata
Release files for pytest-vnc 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_vnc-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for pytest_vnc-2.0.0-py3-none-any.whl |
Release files / pytest_vnc-2.0.0-py3-none-any.whl
| Download URL | pytest_vnc-2.0.0-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
22e8610244f2762fcec6b204c6a39e8b85eb1fe1e23d7f8c6c2cb5100f1c1ae8
|
|
BLAKE2b-256 checksum How to use checksums |
2e380d6b73ab9c640f097e1dfda3003e38ce03675e0a4c19b2bfd2aa180ae6d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Security for pytest-vnc 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.