Skip to main content

🤖 Qubot

An autonomous exploratory testing library for Python.

About

Qubot was created out of inspiration to create a fully autonomous testing bot to mimic a real-life QA-tester.

See the Qubot paper to learn more about the design decisions and the Q-learning approach behind this repository. Moreover, see experiments.ipynb for the experiment mentioned in paper.

Hours of painstaking work have been put into this project thus far, and we hope this library finds actual use in the field of autonomous software testing.

Getting Started

To get started with Qubot, simply download the library into your project's repository from PyPi:

pip install qubot

This will download all necessary dependencies, as well as install the qubot command line program in your current Python environment.

Run Programmatically

You can specify each aspect of your test programmatically, and run it all within the same code file.

from qubot import Qubot, QubotConfigTerminalInfo, QubotConfigModelParameters, QubotDriverParameters, QubotPresetRewardFunc

qb = Qubot(
    url_to_test="https://upmed-starmen.web.app/",
    terminal_info_testing=QubotConfigTerminalInfo(
        terminal_ids=[],
        terminal_classes=["SignIn_login_hcp__qYuvP"],
        terminal_contains_text=[],
    ),
    terminal_info_training=QubotConfigTerminalInfo(
        terminal_ids=[],
        terminal_classes=[],
        terminal_contains_text=["Log in as a Healthcare Provider"],
    ),
    driver_params=QubotDriverParameters(
        use_cache=False,
        max_urls=10,
    ),
    model_params=QubotConfigModelParameters(
        alpha=0.5,
        gamma=0.6,
        epsilon=1,
        decay=0.01,
        train_episodes=1000,
        test_episodes=100,
        step_limit=100,
    ),
    reward_func=QubotPresetRewardFunc.ENCOURAGE_EXPLORATION,
    input_values={
        "color": "#000000",
        "date": "2021-01-01",
        "datetime-local": "2021-01-01T01:00",
        "email": "johndoe@gmail.com",
        "month": "2021-01",
        "number": "1",
        "password": "p@ssw0rd",
        "search": "query",
        "tel": "123-456-7890",
        "text": "text",
        "time":  "00:00:00.00",
        "url": "https://www.google.com/",
        "week": "2021-W01"
    }
)
qb.run()
print(qb.get_stats())

See the source code for descriptions of each configuration property. If you'd like to stick with default values, your Qubot instantiation may look as short as the following:

qb = Qubot(
    url_to_test="https://upmed-starmen.web.app/",
    QubotConfigTerminalInfo(
        terminal_ids=[],
        terminal_classes=["SignIn_login_hcp__qYuvP"],
        terminal_contains_text=[],
    )
)

Run Programmatically via a Configuration File

Shorten the Qubot setup code by adding a Qubot configuration JSON file in the same directory, as follows:

qu_config.json
{
	"url": "https://upmed-starmen.web.app/",
	"terminal_info": {
		"training": {
            "ids": [],
            "classes": [
                "SignIn_login_hcp__qYuvP"
            ],
            "contains_text": []
		},
		"testing": {
            "ids": [],
            "classes": [],
            "contains_text": [
                "Log in as a Healthcare Provider"
            ]
		}
	},
	"driver_parameters": {
	    "use_cache": false,
	    "max_urls": 1
	},
	"model_parameters": {
		"alpha": 0.5,
		"gamma": 0.6,
		"epsilon": 1,
		"decay": 0.01,
		"train_episodes": 1000,
		"test_episodes": 100,
		"step_limit": 100
	},
	"reward_func": 3,
	"input_values": {
        "color": "#000000",
        "date": "2021-01-01",
        "datetime-local": "2021-01-01T01:00",
        "email": "johndoe@gmail.com",
        "month": "2021-01",
        "number": "1",
        "password": "p@ssw0rd",
        "search": "query",
        "tel": "123-456-7890",
        "text": "text",
        "time":  "00:00:00.00",
        "url": "https://www.google.com/",
        "week": "2021-W01"
	}
}

Then, run the following code to set up and execute the Qubot tests.

main.py
from qubot import Qubot

qb = Qubot.from_file('./qu_config.json')
qb.run()
print(qb.get_stats())

Run in Command-Line via a Configuration File

Qubot is automatically installed to your command line when you run pip install qubot.

Assuming you've defined the configuration in ./qu_config.json, enter the following into your command line to run a test:

qubot ./qu_config.json

The above will generate an output file called qu_stats.json in the same directory. To change the name of this output file, you can add the --output_file/-o flag:

qubot ./qu_config.json -o output_stats.json

See this usage statement for more info on the command line utility:

usage: qubot [-h] config_file [--output_file OUTPUT_FILE]

Retrieving Test Statistics

What good is a testing suite without stats?

To retrieve output statistics on your latest test run in code, simply call Qubot(...).get_stats() This is exemplified above.

Meanwhile, output statistics will be written to a file (default: qu_stats.json) if using the command line program.

Statistics have no defined shape, but generally look like the following:

{
    "elements_encountered": {
        "count": 80,
        "events": [
            "<html id=\"\" class=\"\"> (bccad3ad-f444-c74a-a440-631241a8dfc3)",
            "<head id=\"\" class=\"\"> (12bf4d04-00df-2541-8b82-1476d4467471)",
            "<meta id=\"\" class=\"\"> (768ecfcb-5f5d-6945-96a6-6a8e6884d8a9)",
            "<link id=\"\" class=\"\"> (34f6f1d4-7b65-5f4b-b92c-fa5ec96e480d)",
            ...
        ]
    },
    "elements_left_clicked": {
        "count": 7,
        "events": [
            "<a id=\"\" class=\"text-left pt-2 pb-2\"> (ad1272a9-2a5a-2844-b741-39a7fbaf6aff)",
            ...
        ]
    },
    "step_count": 110000,
    "reward_sum": -1100000,
    "training_rewards": {
        "count": 1000,
        "events": [
            -1000,
            -2000,
            ...
        ]
    },
    "epsilon_history": {
        "count": 1000,
        "events": [
            1.0,
            0.9901493354116764,
            0.9803966865736877,
            ...
        ]
    },
    "testing_rewards": {
        "count": 100,
        "events": [
            -1000,
            ...
        ]
    },
    "testing_penalties": {
        "count": 100,
        "events": [
            100,
            ...
        ]
    }
}

Authors

Anthony Krivonos
Portfolio | GitHub

Kenneth Chuen
GitHub

Created for the COMSE6156 - Topics in Software Engineering course at Columbia University in Spring 2021.

Metadata

Release files for qubot 0.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qubot 0.0.13
File Size Uploaded Provenance Actions
qubot-0.0.13.tar.gz 20.5 kB Without provenance Details for qubot-0.0.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qubot 0.0.13
File Interpreter ABI Platform Actions
qubot-0.0.13-py3-none-any.whl Python 3 none any Details for qubot-0.0.13-py3-none-any.whl

Total release size: 42.3 kB

Release files / qubot-0.0.13.tar.gz

Download URL qubot-0.0.13.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4a01e50add6d9bbe8972fc92aa6c7a1d755c7c9f2f59c2055b5b8c4ee992a9e6
BLAKE2b-256 checksum
How to use checksums
d848ad5c8f4117df25632eae57b63f63c043e1143a493938d861880f2a414bea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / qubot-0.0.13-py3-none-any.whl

Download URL qubot-0.0.13-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f31d0625087203621c99ef79dca019c1039623d0ebd9f294c156acdbd4727d4
BLAKE2b-256 checksum
How to use checksums
92e27c7503a10f2ac7e9e8a12610a6c95bf0f400abbb7b6bcb1938e4d2888309
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Security for qubot 0.0.13

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page