Virtualbox helper
This library helps to automate UI tasks on a Virtualbox machine using OpenCV.
It's based on remotevbox to interact with the SOAP service and OpenCV to
perform region detection.
Features:
- can start the
vboxwebsrvSOAP server programmatically and shut it down - match a region of the screen with a given fragment
- wait for a fragment and click on its center
- store if required a representation of the area it matched
- accepts images as NumPy ndarray, raw bytes of filesystem paths
Installation
python3 -m pip install virtualbox_helper
Example usage
from virtualbox_helper import (
ensure_server_running,
get_machine,
wait_for_fragment,
wait_click_on_fragment,
)
# this starts the server and stops it when the interpreter exits
# or you can use the command vboxwebsrv manually
ensure_server_running()
machine = get_machine('vbox', 'yourpassphrase', 'Debian testing')
machine.launch()
no_match = detect_fragment(screenshot_data, 'some/random_image.png')
assert no_match is None
detection = detect_fragment(screenshot_data, 'valid_element.png')
assert detection is not None
# similarity score
assert detection[0] > 0.9
# coordinates of the bounding box that was detected
assert detection[1] == (19, 59)
assert detection[2] == (172, 114)
# raw bytes or a numpy (X, Y, 3) matrix can be used instead of a file path
button_data = open('button.png', 'rb').read()
target = wait_click_on_fragment(machine, button_data, timeout=60.0)
# target has the same structure of match above
wait_for_fragment(machine, 'some/element/to/wait_for.png')
with open('screenshot.png', 'wb') as f:
screenshot_data = machine.take_screenshot_to_bytes()
f.write(screenshot_data)
# this functionality is part of remotevbox
machine.send_character_string('hello world')
machine.send_key_combination(['<enter>'])
machine.poweroff()
When shoulkd I use this?
Hopefully never! If you have a proper API for what you want to automate,
go with that.
To automate UI operations look into PyAutoGUI, and Selenium or Puppeteer
for the web.
However, if you can't do that, for example if you are writing tests for TempleOS or something weird, then this may be fine.
Tests
The tests are based on pytest, can be run using poetry run test.
They expect a machine called "Debian testing" running Debian 11.
Should be trivial to adapt to some other image.
Metadata
Release files for virtualbox-helper 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| virtualbox_helper-0.1.2.tar.gz | 6.3 kB | Without provenance | Details for virtualbox_helper-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| virtualbox_helper-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for virtualbox_helper-0.1.2-py3-none-any.whl |
Total release size: 12.7 kB
Release files / virtualbox_helper-0.1.2.tar.gz
| Download URL | virtualbox_helper-0.1.2.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbbede8a3742d4da50f96db956983b05b9ea2aab0f101d5ce63dda05997e0a88
|
|
BLAKE2b-256 checksum How to use checksums |
1573b9671b105bafa325ca58e39c8eba1cfc946a107a068fd7f8ee3d9b1df675
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.3 CPython/3.8.6 Darwin/19.6.0
|
Release files / virtualbox_helper-0.1.2-py3-none-any.whl
| Download URL | virtualbox_helper-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5608e1408e68a8ac37644099e55a9119dd1d61c0ae1bf7ff5b307763d64f36f
|
|
BLAKE2b-256 checksum How to use checksums |
7b2fb42722e7acc048e593548c53e14b085fc433decb8f39319b10f7fb06b10e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.3 CPython/3.8.6 Darwin/19.6.0
|
Security for virtualbox-helper 0.1.2
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.