Spaces:
Build error
Build error
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+5
- README.md+3-1
- miniwob-plusplus/.github/FUNDING.ymlAdded+1
- miniwob-plusplus/.github/ISSUE_TEMPLATE/bug.mdAdded+27
- miniwob-plusplus/.github/ISSUE_TEMPLATE/proposal.mdAdded+31
- miniwob-plusplus/.github/ISSUE_TEMPLATE/question.mdAdded+12
- miniwob-plusplus/.github/PULL_REQUEST_TEMPLATE.mdAdded+45
- miniwob-plusplus/.github/stale.ymlAdded+62
- miniwob-plusplus/.github/workflows/build-docs.ymlAdded+47
- miniwob-plusplus/.github/workflows/build-publish.yamlAdded+68
- miniwob-plusplus/.github/workflows/build.ymlAdded+21
- miniwob-plusplus/.github/workflows/pre-commit.ymlAdded+24
- miniwob-plusplus/.gitignoreAdded+143
- miniwob-plusplus/.pre-commit-config.yamlAdded+54
- miniwob-plusplus/CODE_OF_CONDUCT.rstAdded+67
- miniwob-plusplus/CONTRIBUTING.mdAdded+28
- miniwob-plusplus/LICENSEAdded+23
- miniwob-plusplus/README.mdAdded+120
- miniwob-plusplus/docs/.gitignoreAdded+3
- miniwob-plusplus/docs/404.mdAdded+3
- miniwob-plusplus/docs/README.mdAdded+36
- miniwob-plusplus/docs/_scripts/gen_env_list.pyAdded+246
- miniwob-plusplus/docs/_scripts/gen_mds.pyAdded+96
- miniwob-plusplus/docs/_scripts/move_404.pyAdded+16
- miniwob-plusplus/docs/_scripts/utils.pyAdded+51
- miniwob-plusplus/docs/_static/img/custom-environment-1.pngAdded
- miniwob-plusplus/docs/_static/img/example-usage-1.pngAdded
- miniwob-plusplus/docs/_static/img/example-usage-2.pngAdded
- miniwob-plusplus/docs/_static/img/favicon.pngAdded
- miniwob-plusplus/docs/_static/img/miniwobplusplus-github.pngAdded
- miniwob-plusplus/docs/_static/img/miniwobplusplus-text.pngAdded
- miniwob-plusplus/docs/_static/img/miniwobplusplus-text.svgAdded
- miniwob-plusplus/docs/_static/img/miniwobplusplus-white.svgAdded
- miniwob-plusplus/docs/_static/img/miniwobplusplus.svgAdded
- miniwob-plusplus/docs/_static/img/showcase-static.pngAdded
- miniwob-plusplus/docs/_static/img/showcase.gifAdded
- miniwob-plusplus/docs/_static/videos/miniwob.mp4Added+3
- miniwob-plusplus/docs/conf.pyAdded+80
- miniwob-plusplus/docs/content/action_space.mdAdded+171
- miniwob-plusplus/docs/content/basic_usage.mdAdded+135
- miniwob-plusplus/docs/content/custom_environment.mdAdded+164
- miniwob-plusplus/docs/content/demonstrations.mdAdded+46
- miniwob-plusplus/docs/content/getting_started.mdAdded+43
- miniwob-plusplus/docs/content/javascript_api.mdAdded+53
- miniwob-plusplus/docs/content/observation_space.mdAdded+98
- miniwob-plusplus/docs/content/reward.mdAdded+28
- miniwob-plusplus/docs/content/viewing.mdAdded+29
- miniwob-plusplus/docs/environments/.gitkeepAdded
- miniwob-plusplus/docs/index.mdAdded+80
- miniwob-plusplus/docs/requirements.txtAdded+5
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines333435363738394032 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textminiwob-plusplus/docs/_static/img/miniwobplusplus-text.png filter=lfs diff=lfs merge=lfs -textminiwob-plusplus/docs/_static/img/showcase-static.png filter=lfs diff=lfs merge=lfs -textminiwob-plusplus/docs/_static/img/showcase.gif filter=lfs diff=lfs merge=lfs -textminiwob-plusplus/docs/_static/videos/miniwob.mp4 filter=lfs diff=lfs merge=lfs -textminiwob-plusplus/miniwobplusplus-text.png filter=lfs diff=lfs merge=lfs -text
276 unmodified lines277278279280281282283276 unmodified lines```bash# From the OpenEnv repository rootdocker build -t browsergym-env:latest -f envs/browsergym_env/server/Dockerfile .```### Run the Server276 unmodified lines277278279280281282283284285276 unmodified lines```bash# From the OpenEnv repository rootdocker build -t browsergym-env:latest \-f envs/browsergym_env/server/Dockerfile \envs/browsergym_env```### Run the Server
1github: Farama-Foundation123456789101112131415161718192021222324252627---name: Bug Reportabout: Submit a bug reporttitle: "[Bug Report] Bug title"
---
If you are submitting a bug report, please fill in the following details and use the tag [bug].
**Describe the bug**A clear and concise description of what the bug is.
**Code example**Please try to provide a minimal example to reproduce the bug. Error messages and stack traces are also helpful.
**System Info**Describe the characteristic of your environment: * Describe how miniwob-plusplus was installed (pip, docker, source, ...) * What OS/version of Linux you're using. Note that while we will accept PRs to improve Window's support, we do not officially support it. * Python version
**Additional context**Add any other context about the problem here.
### Checklist
- [ ] I have checked that there is no similar [issue](https://github.com/Farama-Foundation/miniwob-plusplus/issues) in the repo (**required**)12345678910111213141516171819202122232425262728293031---name: Proposalabout: Propose changes that are not fixes bugstitle: "[Proposal] Proposal title"---
### Proposal
A clear and concise description of the proposal.
### Motivation
Please outline the motivation for the proposal.Is your feature request related to a problem? e.g.,"I'm always frustrated when [...]".If this is related to another GitHub issue, please link here too.
### Pitch
A clear and concise description of what you want to happen.
### Alternatives
A clear and concise description of any alternative solutions or features you've considered, if any.
### Additional context
Add any other context or screenshots about the feature request here.
### Checklist
- [ ] I have checked that there is no similar [issue](https://github.com/Farama-Foundation/miniwob-plusplus/issues) in the repo (**required**)123456789101112---name: Questionabout: Ask a questiontitle: "[Question] Question title"---
### Question
If you're a beginner and have basic questions, please ask on [r/reinforcementlearning](https://www.reddit.com/r/reinforcementlearning/) or in the [RL Discord](https://discord.com/invite/xhfNqQv) (if you're new please use the beginners channel). Basic questions that are not bugs or feature requests will be closed without reply, because GitHub issues are not an appropriate venue for these.
Advanced/nontrivial questions, especially in areas where documentation is lacking, are very much welcome.123456789101112131415161718192021222324252627282930313233343536373839404142434445# Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
## Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)- [ ] New feature (non-breaking change which adds functionality)- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)- [ ] This change requires a documentation update
### ScreenshotsPlease attach before and after screenshots of the change if applicable.
<!--Example:
| Before | After || ------ | ----- || _gif/png before_ | _gif/png after_ |
To upload images to a PR -- simply drag and drop an image while in edit mode and it should upload the image directly. You can then paste that source into the above before/after sections.-->
# Checklist:
- [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) with `pre-commit run --all-files` (see `CONTRIBUTING.md` instructions to set it up)- [ ] I have commented my code, particularly in hard-to-understand areas- [ ] I have made corresponding changes to the documentation- [ ] My changes generate no new warnings- [ ] I have added tests that prove my fix is effective or that my feature works- [ ] New and existing unit tests pass locally with my changes
<!--As you go through the checklist above, you can mark something as done by putting an x character in it
For example,- [x] I have done this task- [ ] I have not done this task-->1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes staledaysUntilStale: 60
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.daysUntilClose: 14
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)onlyLabels: - more-information-needed
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disableexemptLabels: - pinned - security - "[Status] Maybe Later"
# Set to true to ignore issues in a project (defaults to false)exemptProjects: true
# Set to true to ignore issues in a milestone (defaults to false)exemptMilestones: true
# Set to true to ignore issues with an assignee (defaults to false)exemptAssignees: true
# Label to use when marking as stalestaleLabel: stale
# Comment to post when marking as stale. Set to `false` to disablemarkComment: > This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
# Comment to post when removing the stale label.# unmarkComment: ># Your comment here.
# Comment to post when closing a stale Issue or Pull Request.# closeComment: ># Your comment here.
# Limit the number of actions per hour, from 1-30. Default is 30limitPerRun: 30
# Limit to only `issues` or `pulls`only: issues
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':# pulls:# daysUntilStale: 30# markComment: ># This pull request has been automatically marked as stale because it has not had# recent activity. It will be closed if no further activity occurs. Thank you# for your contributions.
# issues:# exemptLabels:# - confirmed1234567891011121314151617181920212223242526272829303132333435363738394041424344454647name: Build main branch documentation websiteon: push: branches: [master]permissions: contents: writejobs: docs: name: Generate Website runs-on: ubuntu-latest env: SPHINX_GITHUB_CHANGELOG_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3
- uses: actions/setup-python@v4 with: python-version: '3.9'
- name: Install dependencies run: pip install -r docs/requirements.txt
- name: Install MiniWoB++ run: pip install -e .
- name: Build Envs Docs run: python docs/_scripts/gen_mds.py
- name: Build List of Environments run: python docs/_scripts/gen_env_list.py
- name: Build run: sphinx-build -b dirhtml -v docs _build
- name: Move 404 run: mv _build/404/index.html _build/404.html
- name: Update 404 links run: python docs/_scripts/move_404.py _build/404.html
- name: Remove .doctrees run: rm -r _build/.doctrees
- name: Upload to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 with: folder: _build1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768# This workflow will build and (if release) publish Python distributions to PyPI# For more information see:# - https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions# - https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/## derived from https://github.com/Farama-Foundation/PettingZoo/blob/e230f4d80a5df3baf9bd905149f6d4e8ce22be31/.github/workflows/build-publish.ymlname: build-publish
on: push: branches: [main] pull_request: branches: [main] release: types: [published]
jobs: build-wheels: runs-on: ${{ matrix.os }} strategy: matrix: include: - os: ubuntu-latest python: 37 platform: manylinux_x86_64 - os: ubuntu-latest python: 38 platform: manylinux_x86_64 - os: ubuntu-latest python: 39 platform: manylinux_x86_64 - os: ubuntu-latest python: 310 platform: manylinux_x86_64 - os: ubuntu-latest python: 311 platform: manylinux_x86_64
steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies run: python -m pip install --upgrade pip setuptools build - name: Build sdist and wheels run: python -m build - name: Store wheels uses: actions/upload-artifact@v3 with: path: dist
publish: runs-on: ubuntu-latest needs: - build-wheels if: github.event_name == 'release' && github.event.action == 'published' steps: - name: Download dists uses: actions/download-artifact@v3 with: name: artifact path: dist - name: Publish uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }}123456789101112131415161718192021name: buildon: [pull_request, push]
permissions: contents: read # to fetch code (actions/checkout)
jobs: build: runs-on: ubuntu-latest timeout-minutes: 15 strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v2 - run: | docker build -f py.Dockerfile \ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ --tag miniwob-plusplus-docker . - name: Run tests run: docker run --shm-size=256m miniwob-plusplus-docker pytest --timeout=20123456789101112131415161718192021222324
# https://pre-commit.com# This GitHub Action assumes that the repo contains a valid .pre-commit-config.yaml file.name: pre-commiton: pull_request: push: branches: [master]
permissions: contents: read # to fetch code (actions/checkout)
jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: '3.10' - run: pip install pre-commit - run: pre-commit --version - run: pre-commit install - run: pre-commit run --all-files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143# Byte-compiled / optimized / DLL files__pycache__/*.py[cod]*$py.class
# C extensions*.so
# Distribution / packaging.Pythonbuild/develop-eggs/dist/downloads/eggs/.eggs/lib/lib64/parts/sdist/var/wheels/share/python-wheels/*.egg-info/.installed.cfg*.eggMANIFEST
# PyInstaller# Usually these files are written by a python script from a template# before PyInstaller builds the exe, so as to inject date/other infos into it.*.manifest*.spec
# Installer logspip-log.txtpip-delete-this-directory.txt
# Unit test / coverage reportshtmlcov/.tox/.nox/.coverage.coverage.*.cachenosetests.xmlcoverage.xml*.cover*.py,cover.hypothesis/.pytest_cache/cover/
# Translations*.mo*.pot
# Django stuff:*.loglocal_settings.pydb.sqlite3db.sqlite3-journal
# Flask stuff:instance/.webassets-cache
# Scrapy stuff:.scrapy
# Sphinx documentationdocs/_build/
# PyBuilder.pybuilder/target/
# Jupyter Notebook.ipynb_checkpoints
# IPythonprofile_default/ipython_config.py
# pyenv# For a library or package, you might want to ignore these files since the code is# intended to run in multiple environments; otherwise, check them in:# .python-version
# pipenv# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.# However, in case of collaboration, if having platform-specific dependencies or dependencies# having no cross-platform support, pipenv may install dependencies that don't work, or not# install all needed dependencies.#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow__pypackages__/
# Celery stuffcelerybeat-schedulecelerybeat.pid
# SageMath parsed files*.sage.py
# Environments.env.venvenv/venv/ENV/env.bak/venv.bak/
# Spyder project settings.spyderproject.spyproject
# Rope project settings.ropeproject
# mkdocs documentation/site
# mypy.mypy_cache/.dmypy.jsondmypy.json
# Pyre type checker.pyre/
# pytype static type analyzer.pytype/
# Cython debug symbolscython_debug/
# vi*~*.swp*.swo123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354---repos: - repo: https://github.com/python/black rev: 23.3.0 hooks: - id: black - repo: https://github.com/codespell-project/codespell rev: v2.2.4 hooks: - id: codespell exclude: ^(miniwob/html/)|(viewer/)|(.*\.svg$) args: - --ignore-words-list=sur,vally,nam - repo: https://github.com/PyCQA/flake8 rev: 6.0.0 hooks: - id: flake8 args: - '--per-file-ignores=*/__init__.py:F401' - --max-complexity=30 - --max-line-length=456 - --show-source - --statistics - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/pycqa/pydocstyle rev: 6.3.0 # pick a git hash / tag to point to hooks: - id: pydocstyle exclude: ^(tests/)|(miniwob/envs/) args: - --source - --explain - --convention=google additional_dependencies: ["toml"] - repo: https://github.com/asottile/pyupgrade rev: v3.4.0 hooks: - id: pyupgrade args: ["--py37-plus"] - repo: local hooks: - id: pyright name: pyright entry: pyright language: node pass_filenames: false types: [python] additional_dependencies: ["pyright@1.1.308"] args: - --project=pyproject.toml12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667=================================Farama Foundation Code of Conduct=================================
The Farama Foundation is dedicated to providing a harassment-free experience foreveryone, regardless of gender, gender identity and expression, sexualorientation, disability, physical appearance, body size, age, race, orreligion. We do not tolerate harassment of participants in any form.
This code of conduct applies to all Farama Foundation repositories (including Gistcomments) both online and off. Anyone who violates this code ofconduct may be sanctioned or expelled from these spaces at thediscretion of the moderators.
We may add additional rules over time, which will be made clearlyavailable to participants. Participants are responsible for knowingand abiding by these rules.
-------------Our Standards-------------Members of the Farama Foundation community are **open**, **inclusive**, and **respectful**.Examples of behavior that contributes to a positive environment for our community include:
* **Being open**. Members of the community are open to collaboration, whether it's on issues, PRs, problems, or otherwise* **Focusing on what is best for the community**. We're respectful of the processes set forth in the community, and we work within them to improve the community.* **Being respectful of differing viewpoints and experiences.** We're receptive to constructive comments and criticism, as the experiences and skill sets of other members contribute to the whole of our efforts.* **Showing empathy.** We're attentive in our communications, and we're tactful when approaching differing views.* **Being respectful.** We're respectful of differing opinions, viewpoints, experiences, and efforts.* **Gracefully accepting constructive criticism.** When we disagree, we are courteous in raising our issues.* **Using welcoming and inclusive language.** We're accepting of all who wish to take part in our activities, fostering an environment where anyone can participate and everyone can make a difference.
Examples of unacceptable behavior include:
* Harassment of any participants in any form.* The use of sexual language or imagery, and sexual attention or advances of any kind.* Insults, put downs, or jokes that are based upon stereotypes, that are exclusionary, or that hold others up for ridicule.* Publishing others' private information, such as a physical or email address, without explicit permission.* Incitement of violence or harassment towards any individual, including encouraging a person to commit suicide or to engage in self-harm.* Sustained disruption of online community discussions, in-person presentations, or other in-person events.* Creating additional online accounts in order to harass another person or circumvent a ban* Other conduct which could reasonably be considered inappropriate in a professional setting including people of many different backgrounds.
Members asked to stop any inappropriate behavior are expected to comply immediately.
------------Consequences------------If a participant engages in behavior that violates this code of conduct, the Farama Foundation team may take any action they deemappropriate, including warning the offender or expulsion from the community.
Thank you for helping make this a welcoming, friendly community for everyone.
-------License-------This Code of Conduct is licensed under the `Creative Commons Attribution-ShareAlike 3.0 Unported License<https://creativecommons.org/licenses/by-sa/3.0/>`_.
-----------Attribution-----------This Code of Conduct is adapted from `Python's Code of Conduct <https://www.python.org/psf/conduct/>`_, which is under a `Creative Commons License<https://creativecommons.org/licenses/by-sa/3.0/>`_.12345678910111213141516171819202122232425262728# MiniWoB++ Contribution Guidelines
We welcome:
- Bug reports- Pull requests for bug fixes- Documentation improvements
## Contributing to the codebase
### Coding
Contributing code is done through standard github methods:
1. Fork this repo2. Commit your code3. Submit a pull request. It will be reviewed by maintainers and they'll give feedback or make requests as applicable
### Considerations- Make sure your new code is properly tested and fully-covered- Any fixes to environments should include fixes to the appropriate documentation
### Git hooksThe CI will run several checks on the new code pushed to the MiniWoB++ repository. These checks can also be run locally without waiting for the CI by following the steps below:1. [install `pre-commit`](https://pre-commit.com/#install),2. install the Git hooks by running `pre-commit install`.
Once those two steps are done, the Git hooks will be run automatically at every new commit. The Git hooks can also be run manually with `pre-commit run --all-files`, and if needed they can be skipped (not recommended) with `git commit --no-verify`. **Note:** you may have to run `pre-commit run --all-files` manually a couple of times to make it pass when you commit, as each formatting tool will first format the code and fail the first time but should pass the second time.1234567891011121314151617181920212223The MIT License
Copyright 2016 OpenAI (as part of https://github.com/openai/universe)Copyright 2018 The Board of Trustees of The Leland Stanford Junior UniversityCopyright 2022 Farama Foundation
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120<p align="center"> <img src="https://raw.githubusercontent.com/Farama-Foundation/miniwob-plusplus/master/miniwobplusplus-text.png" width="500px"/></p>
[](https://pre-commit.com/)[](https://github.com/psf/black)
<p align="center"> <img src="https://raw.githubusercontent.com/Farama-Foundation/miniwob-plusplus/master/docs/_static/img/showcase-static.png" width="100%"/></p>
The MiniWoB++ (Mini World of Bits++) library contains a collection of over 100 **web interaction environments**,along with JavaScript and Python interfaces for programmatically interacting with them.The Python interface follows the [Gymnasium](https://gymnasium.farama.org/) APIand uses [Selenium WebDriver](https://www.selenium.dev/documentation/webdriver/)to perform actions on the web browser.
MiniWoB++ is an extension of the[OpenAI MiniWoB benchmark](http://proceedings.mlr.press/v70/shi17a/shi17a.pdf),and was introduced in the paper[Reinforcement Learning on Web Interfaces using Workflow-GuidedExploration](https://arxiv.org/abs/1802.08802).
The documentation website is at [miniwob.farama.org](https://miniwob.farama.org/).Development on MiniWoB++ is currently ongoing to bring it up to [Farama Standards](https://farama.org/project_standards.html) for mature projects, and will be maintained long term after this point. See the [Project Roadmap](https://github.com/Farama-Foundation/miniwob-plusplus/issues/58) for more details. If you'd like to help out, you can join our discord server here: <https://discord.gg/PfR7a79FpQ>.
# Installation
MiniWoB++ supports Python 3.8+ on Linux and macOS.
## Installing the MiniWoB++ Library
To install the MiniWoB++ library, use `pip install miniwob`.
## Installing Chrome/Chromium and ChromeDriver
We strongly recommend using Chrome or Chromium as the web browser,as other browsers may render the environments differently.
The MiniWoB++ Python interface uses [Selenium](https://www.selenium.dev/documentation/webdriver/),which interacts with the browser via the [WebDriver API](https://w3c.github.io/webdriver/).Follow one of the[instruction methods](https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/)to install ChromeDriver. The simplest method is to[download](https://chromedriver.chromium.org/downloads) ChromeDriver with the matching version,unzip it, and then add the directory containing the `chromedriver` executable to the `PATH` environment variable:
```shexport PATH=$PATH:/path/to/chromedriver```
For Chromium, the driver may also be available in a software package; for example, in Debian/Ubuntu:
```shsudo apt install chromium-driver```
# Example Usage
The following code performs a deterministic action on the[`click-test-2`](http://miniwob.farama.org/environments/click-test-2/) environment.
```pythonimport timeimport gymnasiumimport miniwobfrom miniwob.action import ActionTypes
gymnasium.register_envs(miniwob)
env = gymnasium.make('miniwob/click-test-2-v1', render_mode='human')
# Wrap the code in try-finally to ensure proper cleanup.try: # Start a new episode. obs, info = env.reset() assert obs["utterance"] == "Click button ONE." assert obs["fields"] == (("target", "ONE"),) time.sleep(2) # Only here to let you look at the environment. # Find the HTML element with text "ONE". for element in obs["dom_elements"]: if element["text"] == "ONE": break
# Click on the element. action = env.unwrapped.create_action(ActionTypes.CLICK_ELEMENT, ref=element["ref"]) obs, reward, terminated, truncated, info = env.step(action)
# Check if the action was correct. print(reward) # Should be around 0.8 since 2 seconds has passed. assert terminated is True time.sleep(2)
finally: env.close()```
See [the documentation](http://miniwob.farama.org/content/basic_usage/) for more information.
# Environments
The list of the environments that were included in the MiniWoB++ library can be found in the[documentation](http://miniwob.farama.org/environments/list/).All environments share the same [observation space](http://miniwob.farama.org/content/observation_space/),while the [action space](http://miniwob.farama.org/content/action_space/) can be configured during environment construction.
# Citation
To cite this project please use:
```bibtex@inproceedings{liu2018reinforcement, author = {Evan Zheran Liu and Kelvin Guu and Panupong Pasupat and Tianlin Shi and Percy Liang}, title = {Reinforcement Learning on Web Interfaces using Workflow-Guided Exploration}, booktitle = {International Conference on Learning Representations ({ICLR})}, url = {https://arxiv.org/abs/1802.08802}, year = {2018},}```123environments/*.md_build/demos/123# 404 - Page Not Found
## The requested page could not be found.123456789101112131415161718192021222324252627282930313233343536# MiniWoB++ documentation
This directory contains the documentation for MiniWoB++.
For more information about how to contribute to the documentation go to our [CONTRIBUTING.md](https://github.com/Farama-Foundation/Celshast/blob/main/CONTRIBUTING.md)
## Build the Documentation
Install the required packages and Gymnasium (or your fork):
```pip install -r docs/requirements.txtpip install -e .```
To generate the environment pages:
```python docs/_scripts/gen_mds.pypython docs/_scripts/gen_env_list.py```
To build the documentation once:
```cd docssphinx-build . _build```
To rebuild the documentation automatically every time a change is made:
```pip install sphinx-autobuildcd docssphinx-autobuild . _build```123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246"""Generate Environments List page content."""import os
import gymnasium as gymimport pandas as pd
import miniwobfrom utils import extract_description_from_docstring, get_all_registered_miniwob_envs
gym.register_envs(miniwob)gym.logger.set_level(gym.logger.DISABLED)
ENV_TYPES = [ { "name": "Original Tasks", "description": "These are the original MiniWoB tasks.", "envs": [ "bisect-angle", "book-flight", "choose-date", "choose-list", "circle-center", "click-button", "click-button-sequence", "click-checkboxes", "click-collapsible", "click-collapsible-2", "click-color", "click-dialog", "click-dialog-2", "click-link", "click-menu", "click-menu-2", "click-option", "click-pie", "click-scroll-list", "click-shades", "click-shape", "click-tab", "click-tab-2", "click-test", "click-test-2", "click-widget", "copy-paste", "copy-paste-2", "count-shape", "count-sides", "drag-box", "drag-circle", "drag-cube", "drag-items", "drag-items-grid", "drag-shapes", "drag-sort-numbers", "email-inbox", "enter-date", "enter-password", "enter-text", "enter-text-2", "enter-text-dynamic", "enter-time", "find-midpoint", "find-word", "focus-text", "focus-text-2", "grid-coordinate", "guess-number", "highlight-text", "highlight-text-2", "identify-shape", "login-user", "navigate-tree", "number-checkboxes", "read-table", "read-table-2", "resize-textarea", "right-angle", "scroll-text", "scroll-text-2", "search-engine", "simple-algebra", "simple-arithmetic", "social-media", "terminal", "text-editor", "text-transform", "tic-tac-toe", "use-autocomplete", "use-colorwheel", "use-colorwheel-2", "use-slider", "use-slider-2", "use-spinner", "visual-addition", ], }, { "name": "No-delay Tasks", "description": """The UI elements in some tasks have animation delaysor change the state when the browser is defocused.We provide the "no-delay" version without these issues.""", "envs": [ "book-flight-nodelay", "choose-date-nodelay", "click-collapsible-nodelay", "click-collapsible-2-nodelay", "click-pie-nodelay", "use-autocomplete-nodelay", ], }, { "name": "Additional Tasks", "description": """These tasks were introduced in MiniWoB++.Some are harder versions of the existing tasks, while some are completely new.""", "envs": [ "click-checkboxes-large", "click-checkboxes-soft", "click-checkboxes-transfer", "click-tab-2-hard", "login-user-popup", "multi-layouts", "multi-orderings", "social-media-all", "social-media-some", "email-inbox-forward-nl", "email-inbox-forward-nl-turk", "email-inbox-nl-turk", ], }, { "name": "Debug Tasks", "description": "These are easier versions of existing tasks, suitable for debugging.", "envs": [ "choose-date-easy", "choose-date-medium", "click-tab-2-easy", "click-tab-2-medium", "click-test-transfer", "email-inbox-delete", "email-inbox-forward", "email-inbox-important", "email-inbox-noscroll", "email-inbox-reply", "email-inbox-star-reply", "unicode-test", ], }, { "name": "Flight Search Tasks", "description": """These are ports of the FormWoB tasks in the original World of Bits paper.,* The prompt is a list of key-value pairs (e.g., Departure City: New York).* If the required fields are not filled, or if the agent navigates away from the page, the reward is -1.,* Otherwise, the reward is the fraction of key-value pairs that are satisfied.""", "envs": ["flight.Alaska", "flight.Alaska-auto", "flight.AA"], }, { "name": "Hidden Test Tasks", "description": "These are tasks intended to be used as the hidden test set. They were originally not available from the OpenAI website.", "envs": [ "ascending-numbers", "buy-ticket", "daily-calendar", "drag-single-shape", "drag-shapes-2", "draw-circle", "draw-line", "find-greatest", "form-sequence", "form-sequence-2", "form-sequence-3", "generate-number", "hot-cold", "odd-or-even", "order-food", "phone-book", "sign-agreement", "stock-market", ], },]
# Get environment descriptionsENVS_DESCRIPTIONS = {}filtered_envs = get_all_registered_miniwob_envs()for env_spec in filtered_envs: try: env_spec = gym.spec(env_spec.id)
split = env_spec.entry_point.split(":") mod = __import__(split[0], fromlist=[split[1]]) env_class = getattr(mod, split[1]) docstring = env_class.__doc__
if not docstring: docstring = env_class.__class__.__doc__
description = extract_description_from_docstring(docstring) ENVS_DESCRIPTIONS[env_spec.name] = description except Exception as e: print(e)
file_start_content = """# Environments List
```{toctree}:hidden::glob:
../environments/*```
"""
list_md_path = os.path.join(os.path.dirname(__file__), "..", "environments", "list.md")with open(list_md_path, "w") as fp: content = file_start_content for env_type in ENV_TYPES: df = pd.DataFrame( { "Name": [f"[{env}](./{env})" for env in env_type["envs"]], "Description": [ENVS_DESCRIPTIONS[env] for env in env_type["envs"]], } ) type_name = env_type["name"] type_desc = env_type["description"] content += f"## {type_name}\n\n" content += f"{type_desc}\n\n" content += df.to_markdown(index=False) + "\n\n"
content += """## Excluded Tasks
The following tasks require the agent to wait for events to happen before acting,and a 'no-delay' version is impossible to make.
| Name | Description ||:------------ |:---------------------------------------------------------------- || chase-circle | Keep your mouse inside a moving circle. || moving-items | Click moving items before they disappear. || simon-says | Push the buttons in the order shown. || button-delay | Wait a certain period of time before clicking the second button. || hover-shape | Hover over the colored shape. |""" fp.write(content)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596"""Generate markdown files for the environments."""import osimport shutil
import gymnasium as gym
import miniwobfrom utils import get_all_registered_miniwob_envs, trim_docstring
LAYOUT = "env"
gym.register_envs(miniwob)gym.logger.set_level(gym.logger.DISABLED)
# Copy MiniWoB-plusplus/miniwob/html to /docs/demos/source_path = os.path.join( os.path.dirname(__file__), "..", "..", "miniwob", "html",)# Sphinx copies everything inside the first demos/ directory to the root# So to ensure that the final path is /demos/** we need another demos folderdestination_path = os.path.join(os.path.dirname(__file__), "..", "demos", "demos")shutil.copytree(source_path, destination_path)
# Update Docsfiltered_envs = get_all_registered_miniwob_envs()for i, env_spec in enumerate(filtered_envs): print("ID:", env_spec.id) try: env_spec = gym.spec(env_spec.id)
split = env_spec.entry_point.split(":") mod = __import__(split[0], fromlist=[split[1]]) env_class = getattr(mod, split[1]) docstring = env_class.__doc__
if not docstring: docstring = env_class.__class__.__doc__
docstring = trim_docstring(docstring)
env_type = "miniwob" env_name = env_spec.name title_env_name = env_name
# path for saving the markdown file md_path = os.path.join( os.path.dirname(__file__), "..", "environments", env_name + ".md", ) os.makedirs(os.path.dirname(md_path), exist_ok=True)
front_matter = f"""---autogenerated:title: {title_env_name}---""" title = f"# {title_env_name}" if env_name.startswith("flight."): url = f'../../demos/{env_name.replace(".", "/")}/wrapper.html' info = f"""<center> <a href="{url}" target="_blank"><button>Open demo in a separate tab.</button></a></center>""" else: url = f"../../demos/miniwob/{env_name}.html" info = f"""<center> <iframe src="{url}" width="325" height="210" scrolling="no" style="overflow:hidden;"> </iframe><br> <a href="{url}" target="_blank"><button>Open demo in a separate tab.</button></a></center>""" if docstring is None: docstring = "No information provided" all_text = f"""{front_matter}{title}
{info}
{docstring}""" file = open(md_path, "w", encoding="utf-8") file.write(all_text) file.close() except Exception as e: print(e)12345678910111213141516"""Move 404.md to the _build directory."""import sys
if __name__ == "__main__": if len(sys.argv) < 2: print("Provide a path") filePath = sys.argv[1]
with open(filePath, "r+") as fp: content = fp.read() content = content.replace('href="../', 'href="/').replace('src="../', 'src="/') fp.seek(0) fp.truncate()
fp.write(content)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051"""Utilities for documentation generation."""import logging
import gymnasium as gym
def get_all_registered_miniwob_envs(): """Return all registered MiniWoB environments.""" envs = [] for env_spec in gym.registry.values(): if env_spec.namespace == "miniwob": envs.append(env_spec) return sorted(envs, key=lambda x: x.name)
def trim_docstring(docstring): """Format whitespaces in the docstring.""" if not docstring: return "" # Convert tabs to spaces (following the normal Python rules) # and split into a list of lines: lines = docstring.expandtabs().splitlines() # Determine minimum indentation (first line doesn't count): indent = 232323 for line in lines[1:]: stripped = line.lstrip() if stripped: indent = min(indent, len(line) - len(stripped)) # Remove indentation (first line is special): trimmed = [lines[0].strip()] if indent < 232323: for line in lines[1:]: trimmed.append(line[indent:].rstrip()) # Strip off trailing and leading blank lines: while trimmed and not trimmed[-1]: trimmed.pop() while trimmed and not trimmed[0]: trimmed.pop(0) # Return a single string: return "\n".join(trimmed)
def extract_description_from_docstring(docstring): """Extract the task description for the docstring.""" if not docstring: return "" lines = [line.strip() for line in docstring.splitlines() if line.strip()] if lines[0] != "## Description": logging.warning(f"Invalid docstring header: {lines[0]}") return "" return lines[1]123version https://git-lfs.github.com/spec/v1oid sha256:880884a37094c4b81fd122c49a17d77d72f05449da449d6a577d4e9608e80366size 14280631234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980"""Configuration file for the Sphinx documentation builder."""# This file only contains a selection of the most common options. For a full# list see the documentation:# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,# add these directories to sys.path here. If the directory is relative to the# documentation root, use os.path.abspath to make it absolute, like shown here.## import os# import sys# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------import miniwob
project = "MiniWoB++"copyright = "2023 Farama Foundation"author = "Farama Foundation"
# The full version, including alpha/beta/rc tagsrelease = miniwob.__version__
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom# ones.extensions = [ "sphinx.ext.napoleon", "sphinx.ext.doctest", "sphinx.ext.autodoc", "sphinx.ext.githubpages", "sphinx.ext.viewcode", "myst_parser",]
# Add any paths that contain templates here, relative to this directory.templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and# directories to ignore when looking for source files.# This pattern also affects html_static_path and html_extra_path.exclude_patterns = []
# Napoleon settingsnapoleon_use_ivar = Truenapoleon_use_admonition_for_references = True# See https://github.com/sphinx-doc/sphinx/issues/9119napoleon_custom_sections = [("Returns", "params_style")]
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for# a list of builtin themes.#html_theme = "furo"html_title = "MiniWoB++ Documentation"html_baseurl = "https://miniwob.farama.org"html_copy_source = Falsehtml_favicon = "_static/img/favicon.png"html_theme_options = { "light_logo": "img/miniwobplusplus.svg", "dark_logo": "img/miniwobplusplus-white.svg", "description": "A collection of over 100 web interaction environments, along with JavaScript and Python interfaces.", "image": "img/miniwobplusplus-github.png", "source_repository": "https://github.com/Farama-Foundation/miniwob-plusplus/", "source_branch": "master", "source_directory": "docs/", "versioning": True, "gtag": "G-PR9ZPS99C2",}
html_static_path = ["_static"]html_extra_path = ["demos"]html_css_files = []123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171# Action Space
An action is specified by an **action type** (e.g., `CLICK_COORDS`)and the necessary fields for that action type (e.g., `coords=[30, 60]`).
## Supported Action Types
MiniWoB++ environments support the following action types:
```{list-table}:header-rows: 1* - Name - Description* - `NONE` - Do nothing for the current step.* - `MOVE_COORDS` - Move the cursor to the specified coordinates.* - `CLICK_COORDS` - Click on the specified coordinates.* - `DBLCLICK_COORDS` - Double-click on the specified coordinates.* - `MOUSEDOWN_COORDS` - Start dragging on the specified coordinates.* - `MOUSEUP_COORDS` - Stop dragging on the specified coordinates.* - `SCROLL_UP_COORDS` - Scroll up on the mouse wheel at the specified coordinates.* - `SCROLL_DOWN_COORDS` - Scroll down on the mouse wheel at the specified coordinates.* - `CLICK_ELEMENT` - Click on the specified element using JavaScript.* - `PRESS_KEY` - Press the specified [key or key combination](#key-combinations).* - `TYPE_TEXT` - Type the specified string.* - `TYPE_FIELD` - Type the value of the specified task field.* - `FOCUS_ELEMENT_AND_TYPE_TEXT` - Click on the specified element using JavaScript, and then type the specified string.* - `FOCUS_ELEMENT_AND_TYPE_FIELD` - Click on the specified element using JavaScript, and then type the value of the specified task field.```
There are action types that perform similar actions (e.g., `CLICK_COORDS` and `CLICK_ELEMENT`).A common practice is to specify a subset of action types that the agent can use in the config, as described below.
(action-configs)=## Action Configs
The list of selected action types, along with other configurations, can be customizedby passing a `miniwob.action.ActionSpaceConfig` object to the `action_space_config` argumentduring environment construction.
An `ActionSpaceConfig` object has the following fields:
```{list-table}:header-rows: 1* - Key - Type - Description* - `action_types` - `Sequence[ActionTypes]` - An ordered sequence of action types to include.* - `screen_width` - `float` - Screen width. Will be overridden by the environment constructor.* - `screen_height` - `float` - Screen height. Will be overridden by the environment constructor.* - `coord_bins` - `tuple[int, int]` - If specified, bin the x and y coordinates to these numbers of bins. Mouse actions will be executed at the middle of the specified partition.* - `scroll_amount` - `int` - The amount to scroll for scroll actions.* - `scroll_time` - `int` - Time in milliseconds to wait for scroll action animation.* - `allowed_keys` - `Sequence[str]` - An ordered sequence of allowed [keys and key combinations](#key-combinations) for the `PRESS_KEY` action.* - `text_max_len` - `int` - Maximum text length for the `TYPE_TEXT` action.* - `text_charset` - `str` or `set[str]` - Character set for the `TYPE_TEXT` action.```
(presets)=### Presets
The following preset names can be specified in place of the `ActionSpaceConfig` object:
* `"all_supported"`: Select all supported actions, including redundant ones.* `"shi17"`: The action space from (Shi et al., 2017) [World of Bits: An Open-Domain Platform for Web-Based Agents](http://proceedings.mlr.press/v70/shi17a/shi17a.pdf).* `"liu18"`: The action space from (Liu et al., 2018) [Reinforcement Learning on Web Interfaces Using Workflow-Guided Exploration](https://arxiv.org/abs/1802.08802).* `"humphreys22"`: The action space from (Humphreys et al., 2022) [A data-driven approach for learning to control computers](https://arxiv.org/abs/2202.08137).
Adding `"_mac_os"` to the preset name will change the key modifiers in `allowed_keys`from Control to Meta.
(key-combinations)=### Key combinations
The `PRESS_KEY` action type issues a key combination via Selenium.Each key combination in the `allowed_keys` config follow the rules:
* Modifiers are specified using prefixes "C-" (Control), "S-" (Shift), "A-" (Alternate), or "M-" (Meta).* Printable character keys (a, 1, etc.) are specified directly. Shifted characters (A, !, etc.) are equivalent to "S-" + non-shifted counterpart.* Special keys are inclosed in "<...>". The list of valid names is specified in `miniwob.constants.WEBDRIVER_SPECIAL_KEYS`.
Example valid key combinations:`"7"`, `"<Enter>"`, `"C-S-<ArrowLeft>"`.
## Action Object
The action passed to the [`step`](https://gymnasium.farama.org/api/env/#gymnasium.Env.step) methodshould be a `dict` whose field inclusion depends on the selected action types in the config:
```{list-table}:header-rows: 1* - Key - Type - Description - Inclusion* - `action_type` - `int` - Action type index from the `action_types` list in the config. - Always.* - `coords` - `np.ndarray` of shape `(2,)` - Left and top coordinates. Depending on the `coord_bins` config, the values can be of type `int8` (binned) or `float32` (unbinned). - When any `*COORDS` action type is selected.* - `ref` - `int` - Element `ref` ID. If no element has the specified `ref`, the action becomes a no-op. - When any `*_ELEMENT*` action type is selected.* - `key` - `int` - Key index from the `allowed_keys` list in the config. - When the `PRESS_KEY` action type is selected.* - `text` - `str` - Text to type. - When any `*_TYPE_TEXT` action type is selected.* - `field` - `int` - Index from the task field list `obs["fields"]`. If the index is out of bound, no text will be typed. - When any `*_TYPE_FIELD` action type is selected.```
For instance, if the config only contains action types `CLICK_COORDS` and `PRESS_KEY`,the action object can be
```pythonaction = { "action_type": 0, # CLICK_COORDS "coords": np.array([100, 50]), "key": 0, # Ignored by the action CLICK_COORDS}```
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135# Basic Usage
## Simple Example
The following code performs a deterministic action on the[`click-test-2`](/environments/click-test-2) environment.
```pythonimport timeimport gymnasiumimport miniwobfrom miniwob.action import ActionTypes
gymnasium.register_envs(miniwob)
env = gymnasium.make('miniwob/click-test-2-v1', render_mode='human')
# Wrap the code in try-finally to ensure proper cleanup.try: # Start a new episode. observation, info = env.reset() assert observation["utterance"] == "Click button ONE." assert observation["fields"] == (("target", "ONE"),) time.sleep(2) # Only here to let you look at the environment. # Find the HTML element with text "ONE". for element in observation["dom_elements"]: if element["text"] == "ONE": break
# Click on the element. action = env.unwrapped.create_action(ActionTypes.CLICK_ELEMENT, ref=element["ref"]) observation, reward, terminated, truncated, info = env.step(action)
# Check if the action was correct. print(reward) # Should be around 0.8 since 2 seconds has passed. assert terminated is True time.sleep(2)
finally: env.close()```
The output should look something like this:
```{image} /_static/img/example-usage-1.png:width: 50%:align: center```
After 2 seconds:
```{image} /_static/img/example-usage-2.png:width: 50%:align: center```
## Environment Initialization
An environment can be created using[`gymnasium.make`](https://gymnasium.farama.org/api/registry/#gymnasium.make):
```pythonenv = gymnasium.make('miniwob/click-test-2-v1', render_mode='human')```
Common arguments include:
* **`render_mode`:** Render mode. Supported values are: - `None` (default): Headless Chrome, which does not show the browser window. - `"human"`: Show the browser window.* **`action_space_config`:** Configuration for the action space. Supported values are: - An [`ActionSpaceConfig`](/content/action_space.md#action-configs) object. - A [preset name](/content/action_space.md#presets), which will instantiate an `ActionSpaceConfig` object.
## Observation Space
```pythonobservation, info = env.reset(seed=42)observation, reward, terminated, truncated, info = env.step(action)```
The [`reset`](https://gymnasium.farama.org/api/env/#gymnasium.Env.reset)and [`step`](https://gymnasium.farama.org/api/env/#gymnasium.Env.step) methodsreturn an observation, which is a `dict` with the following fields:
* **`utterance`:** Task instruction string, such as `"Click button ONE."`.* **`fields`:** Environment-specific key-value pairs extracted from the utterance, such as `(("target", "ONE"),)`.* **`screenshot`:** A numpy array of shape `(height, width, 3)` containing the RGB values.* **`dom_elements`:** A tuple of dicts, each listing properties like the geometry and HTML attributes of a visible DOM element.
For example, the `observation` from the `reset` command above is```python{ 'utterance': 'Click button ONE.', 'fields': (('target', 'ONE'),), 'screenshot': array([[[255, 255, 0], ...], ...], dtype=uint8), 'dom_elements': ( {'ref': 1, 'parent': 0, 'tag': 'body', ...}, {'ref': 2, 'parent': 1, 'tag': 'div', ...}, {'ref': 3, 'parent': 2, 'tag': 'div', ...}, {'ref': 4, 'parent': 3, 'tag': 'button', 'text': 'ONE', ...}, {'ref': 5, 'parent': 3, 'tag': 'button', 'text': 'TWO', ...}, ),}```
See the [Observation Space](/content/observation_space) page for more details.
## Action Space
```pythonaction = env.unwrapped.create_action(ActionTypes.CLICK_ELEMENT, ref=element["ref"])observation, reward, terminated, truncated, info = env.step(action)```
The [`step`](https://gymnasium.farama.org/api/env/#gymnasium.Env.step) methodtakes an `action` object, which should be a `dict` with the following fields:
* **`action_type`:** The action type index from `env.unwrapped.action_space_config.action_types`.* Other fields such as `ref`, `coords`, `text`, etc. should be specified based on the action type. The action space `env.unwrapped.action_space` specifies which fields should be included.
For example, the `action` from the `create_action` command above is```python{ 'action_type': 8, # ActionTypes.CLICK_ELEMENT in the default action config. 'ref': 4, # The button with text 'ONE' from observation['dom_elements']. ... # Other fields are ignored for CLICK_ELEMENT.} ```In actual code, the web agent should generate an action based on the observation.
See the [Action Space](/content/action_space) page for more details.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164# Creating a Custom Environment
Creating a custom MiniWoB++ environment is as simple as creating a new task HTML page, and then specifying the URL to the HTML file when registering the environment.
The following tutorial illustrates how to create a custom environment with the standard [observation space](/content/observation_space) and [action space](/content/action_space). For more advanced needs (customizing the spaces, creating a package, etc.), see this [Gymnasium tutorial](https://gymnasium.farama.org/tutorials/gymnasium_basics/environment_creation/).
## Creating the Task HTML Page
```{image} /_static/img/custom-environment-1.png:width: 50%:align: center```
To properly interface with the MiniWoB++ library, the HTML file must include[`core.css`](https://github.com/Farama-Foundation/miniwob-plusplus/blob/master/miniwob/html/core/core.css)and[`core.js`](https://github.com/Farama-Foundation/miniwob-plusplus/blob/master/miniwob/html/core/core.js).These files are also available from the Python package (under `html/core/`).
Here is an example HTML file (`custom.html`):
```html<!DOCTYPE html><html><head><title>Custom Task</title><!-- The following CSS and JS are required. --><link rel="stylesheet" type="text/css" href="core.css"><script src="core.js"></script><script>// genProblem() will be called at the start of each episode.var genProblem = function() { // core.randi(a, b) (from core.js) samples an integer between a and b (inclusive). let targetAmount = core.randi(2, 5), clickedAmount = 0;
// Set the task utterance. This will become the "utterance" in the observation. document.getElementById("query").textContent = `Click Hello ${targetAmount} times, then click Submit.`;
// Create the task UI. let hello = document.createElement("button"); let submit = document.createElement("button"); let amount = document.createElement("span"); document.getElementById("area").replaceChildren(hello, submit, amount);
hello.textContent = "Hello"; hello.addEventListener("click", () => { clickedAmount++; amount.textContent = clickedAmount; });
submit.textContent = "Submit"; submit.addEventListener("click", () => { if (clickedAmount === targetAmount) { // core.endEpisode(reward, timeProportional) ends the episode and sets // the reward (which can be read by Selenium). If timeProportional is // true, then the reward is scaled by the amount of time left. core.endEpisode(1.0, true); } else { core.endEpisode(-1.0, false); } });}
window.onload = function() { // core.startEpisode() prepares the web page for an episode by showing the "START" // screen (it does not actually start the episode until "START" is clicked). // core.startEpisode() will also be automatically called at the end of each episode. core.startEpisode();}</script></head><body><!-- The following 3 divs are required. --><div id="wrap"> <div id="query"></div> <div id="area"></div></div></body></html>```
## Registering the Environment
The generic environment class `MiniWoBEnvironment` from `miniwob.environment` can be used as the entry point for the environment.The following keyword arguments should be specified:
* `subdomain`: This should match the HTML filename.* `base_url`: This should point to where the HTML is; the URL `{base_url}/{subdomain}.html` should point to the task page.* `field_extractor`: This should be a function that takes the utterance string (that appears in the yellow box) and returns a list of fields as key-value tuples. One option is to not produce any field by specifying `lambda x: []`.
Here is example code (`custom_registry.py`):
```pythonimport pathlibfrom gymnasium.envs.registration import registerfrom miniwob.fields import create_regex_field_extractor
register( id='miniwob/custom-v0', entry_point='miniwob.environment:MiniWoBEnvironment', kwargs={ 'subdomain': 'custom', # Assuming that this file is in the same directory as `custom.html`: 'base_url': 'file://{}/'.format(pathlib.Path(__file__).parent), # This helper method will produce a function that takes a string and returns # [('amount', ___)], where ___ is from the capturing group in the regex. 'field_extractor': create_regex_field_extractor( r'Click Hello (\d+) times, then click Submit\.', ['amount'], ) },)```
## Using the Environment
The following code is adapted from the example in the [Basic Usage](/content/basic_usage) page:
```pythonimport timeimport gymnasiumfrom miniwob.action import ActionTypesfrom miniwob.fields import field_lookup
# Import `custom_registry.py` above to register the task.import custom_registrygymnasium.register_envs(custom_registry)
# Create an environment.env = gymnasium.make('miniwob/custom-v0', render_mode='human')
# Wrap the code in try-finally to ensure proper cleanup.try: # Start a new episode. observation, info = env.reset()
# Find the relevant HTML elements. for hello_button in observation["dom_elements"]: if hello_button["text"] == "Hello": break for submit_button in observation["dom_elements"]: if submit_button["text"] == "Submit": break
amount = int(field_lookup(observation['fields'], 'amount')) for _ in range(amount): # Click Hello. action = env.unwrapped.create_action(ActionTypes.CLICK_ELEMENT, ref=hello_button["ref"]) observation, reward, terminated, truncated, info = env.step(action) time.sleep(0.5)
# Click Submit. action = env.unwrapped.create_action(ActionTypes.CLICK_ELEMENT, ref=submit_button["ref"]) observation, reward, terminated, truncated, info = env.step(action) # Check if the action was correct. assert reward >= 0 assert terminated is True time.sleep(0.5)
finally: env.close()```12345678910111213141516171819202122232425262728293031323334353637383940414243444546# Demonstrations
We have recorded demonstrations from Mechanical Turk and put them in a [separate repository](https://github.com/stanfordnlp/miniwob-plusplus-demos).
## Demonstration Format
Each demonstration is saved as a JSON file. The root object generated by `core/record.js` contains the following fields:
* `taskName` (string)* `utterance` (string)* `reward` (number): Reward as defined by the task* `rawReward` (number): 1 if succeeded and -1 if failed* `states`: a list of state objects * One state is recorded for the initial state * Two states are recorded for each event, one before the event resolves and one after the event resolves
Each state object has the following fields:
* `time` (number): Time elapsed since the episode started* `action`: An action-specific object (not present for the initial state) with the following common keys: * `type` (string) * `timing` (number): the `eventPhase` property of the JS event object. This is 1 before the event resolves (capturing state) and 3 after the event resolves (bubbling state).* `dom`: The DOM info as generated by `getDOMInfo()` * The event target will have a special key `recordingTarget` set to `true`.
## Recording Your Own Demonstrations
1. Start the recording server: ``` # Create an output directory mkdir out/ python -m miniwob.record out/ ```
2. Append `?record=true` to the URL of the task you want to record. For example, for the `click-test` task, go to ``` file:///path/to/miniwob-plusplus/html/miniwob/click-test.html?record=true ``` (Note: For recent versions of Chrome, you might have to retype the whole URL instead of just appending `?record=true`.)
3. To view the results, open `viewer/viewer.html` while the recording server is running. The URL should be like ``` file:///path/to/miniwob-plusplus/html/viewer/viewer.html ```
12345678910111213141516171819202122232425262728293031323334353637383940414243# Getting Started
## Install the MiniWoB++ Library
To install the MiniWoB++ library, use `pip install miniwob`.
Alternatively, clone the repository from GitHub:
```shgit clone https://github.com/Farama-Foundation/miniwob-plusplus.gitcd miniwob-pluspluspip install -e .```
If this gives you problems, try again and add pip's `--ignore-installed` flag.
## Install Chrome/Chromium and ChromeDriver
We strongly recommend using Chrome or Chromium as the web browser,as other browsers may render the environments differently.
The MiniWoB++ Python interface uses [Selenium](https://www.selenium.dev/documentation/webdriver/),which interacts with the browser via the [WebDriver API](https://w3c.github.io/webdriver/).Follow one of the[instruction methods](https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/)to install ChromeDriver. The simplest method is to[download](https://chromedriver.chromium.org/downloads) ChromeDriver with the matching version,unzip it, and then add the directory containing the `chromedriver` executable to the `PATH` environment variable:
```shexport PATH=$PATH:/path/to/chromedriver```
For Chromium, the driver may also be available in a software package; for example, in Debian/Ubuntu:
```shsudo apt install chromium-driver```
## Development Environment
For information about setting up a development environment,see [`CONTRIBUTING.md`](https://github.com/Farama-Foundation/miniwob-plusplus/blob/master/CONTRIBUTING.md).1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253# Javascript API
MiniWoB++ environments incorporate a few JavaScript utilities,many of which are used by the Python interface.
## `Math.seedrandom([seed])`
Sets the global random seed of the environment. The optional argument `seed` can be any object.
## `getDOMInfo()`
Returns a nested object containing information about the current DOM states.The returned object corresponds to the `<body>` element. Its children can be accessed under the `children` field.
Each visible DOM element is converted into an object with the following fields:
* `tag` (string): Tag name * For normal elements, this is the uppercased tag name (e.g., `"DIV"`) * For `<input>` elements, the input type is appended (e.g., `"INPUT_text"`) * Each non-empty text node is converted into pseudo-elements with tag `"t"`, where each pseudo-element represents one line of text. However, if the text node is the only child of the parent. The text pseudo-element is not created, and its text is assigned to the parent element instead.* `ref` (number): Reference number * Within each episode, the `ref` number of the same object stays the same * For the same random seed, the `ref` number of the same object should be the same * `ref` for normal elements start from 1, while `ref` for text psuedo-elements counts down from -1* `children` (list): Recursive list of objects corresponding to the children* `left`, `top`, `width`, `height` (number): Geometry of the element* `id` (string): Element's `id`* `classes` (string): Element's `class`es (space-separated)* `bgColor`, `fgColor` (string): Background and foreground colors* `focused` (boolean): Indicates if the element is being focused on* `tampered` (boolean): Indicates if the element is tampered (clicked, focused, typed, etc.)* `value`: For `<input>`, this contains the input value * For `checkbox` and `radio` types, this contains a boolean whether the input is selected * For other input types, this contains a text value* `text` (string): For child nodes and text pseudo-elements, this contains the text content
## `flattenDOMInfo(rootDomInfo)`
Can be called on the result of `getDOMInfo()` to get a flattened representation.Useful for debugging in Chrome console.
## `elementClick(ref)`
Clicks on an element regardless of its location and visibility.The argument `ref` is the ref value generated by the previous call to `getDOMInfo()`.
## `visualizeAttention(values)`
Visualizes the attention weights on the screen.The argument `values` is a 2D array of shape 20 × 20.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798# Observation Space
## Observation Object
In all MiniWoB++ environments, an observation is a `dict` with the following fields:
```{list-table}:header-rows: 1* - Key - Type - Description* - `utterance` - `str` - Task instruction string.* - `fields` - `tuple[tuple[str, str]]` - Environment-specific key-value pairs extracted from the utterance; e.g., "Click on the OK button" → `(("target", "OK"),)`. The fields are guaranteed to be the same during the same episode.* - `screenshot` - `np.ndarray` with shape `(height, width, 3)` and type `uint8` - Screenshot as RGB values for each pixel.* - `dom_elements` - `tuple[dict]` - Tuple of dicts, each listing properties of a *visible* DOM elements (see below).```
## DOM Element Properties
Each dict in `dom_elements` has the following fields:
```{list-table}:header-rows: 1* - Key - Type - Description* - `ref` - `int` - Non-zero integer ID. * The `ref` for normal HTML elements start from 1. * Each HTML element retains the same `ref` during the same episode. * Non-empty text nodes are converted into pseudo-elements with `ref` counting down from -1.[^1]* - `parent` - `int` - `ref` of the parent. For the root DOM element, `parent` will be 0.* - `left` - `np.ndarray` with shape `(1,)` and type `float32` - Left coordinate relative to the screen (can be negative).* - `top` - `np.ndarray` with shape `(1,)` and type `float32` - Top coordinate relative to the screen (can be negative).* - `width` - `np.ndarray` with shape `(1,)` and type `float32` - Element width.* - `height` - `np.ndarray` with shape `(1,)` and type `float32` - Element height.* - `tag` - `str` - HTML tag. * For normal elements, this is the lowercased tag name (e.g., `"div"`). * For `<input>` elements, the input type is appended (e.g., `"input_text"`). * Non-empty text nodes become pseudo-elements with tag `"t"`.[^1]* - `text` - `str` - Text content, which is non-empty only for leaf elements.[^1]* - `value` - `str` - HTML `value` attribute (for an `<input>` element).* - `id` - `str` - HTML `id` attribute.* - `classes` - `str` - HTML `class` attribute (multiple classes are separated by spaces).* - `bg_color` - `np.ndarray` with shape `(4,)` and type `float32` - Background color as RGBA value.* - `fg_color` - `np.ndarray` with shape `(4,)` and type `float32` - Foreground color as RGBA value.* - `flags` - `np.ndarray` with shape `(4,)` and type `int8` - Binary flags: * (`focused`) Whether the element is being focused on. * (`tampered`) Whether the element has been tampered (clicked, focused, typed, etc.). * (`targeted`) Whether the element is an event target (for recorded demonstrations). * (`is_leaf`) Whether the element is a leaf.```
[^1]: **Note:** Regarding text nodes: * For an element with a single text node as its child (e.g., `<button>Submit</button>`), a text pseudo-element will not be created. The element will become a leaf with the `text` feature filled in. * For an element with a text node as one of its children (e.g., `<button>Submit <b>NOW</b></button>`), a text pseudo-element (negative `ref` and `tag = "t"`) will be created for each line of text in the text node.
12345678910111213141516171819202122232425262728# Reward
In all environments, the reward is 0 during the episode, and a value in the range -1 to 1 (inclusive)when the episode terminates.
## Reward processor
Originally, any positive reward is scaled by the remaining time on the timer.Some environments also give partial rewards for partially correct answers(see the documentation or docstring of each environment for details).
A **reward processor** can be used to returns custom rewards that ignorethe time penalty or partial rewards. A reward processor can be specified duringenvironment initialization:
```pythonimport gymnasiumfrom miniwob.reward import get_binary_reward
env = gymnasium.make('miniwob/ascending-numbers-v1', reward_processor=get_binary_reward)```
The available reward processors include:
* `get_original_reward`: Returns the original reward. This is the default.* `get_raw_reward`: Returns the raw reward without time penalty.* `get_binary_reward`: Returns the binary reward without time penalty or partial reward. The terminal reward will be either -1 or 1. This is used in most previous publications.* `get_thresholded_reward`: Returns the binary reward without time penalty or partial reward, but with any partial reward ≥ the specified threshold being treated as 1. This is needed for tasks that give continuous-valued partial rewards depending on how close the answer is to the correct answer. To specify this method as the reward processor, use `lambda metadata: get_thresholded_reward(metadata, threshold=VALUE)` or `functools.partial(get_thresholded_reward, threshold=VALUE)`.1234567891011121314151617181920212223242526272829# Viewing the Environments
There are 2 ways to view the environments:
* **Run a simple server:**
* **Node.js:** Install and run `http-server` using ``` npm install http-server -g # Requires Node.js cd miniwob/html/ http-server ``` The tasks should now be accessible at `http://localhost:8080/miniwob/`.
* **Python:** ``` cd miniwob/html/ python -m http.server 8080 ``` We found this method to be less stable with a large amount of access, which is required by reinforcement learning.
* **Use the `file://` protocol:** open `miniwob/html/miniwob/` in the browser. * The URL should now be something like file:///path/to/miniwob/html/miniwob/ * This should show the directory listing of all task HTML files.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980---hide-toc: truefirstpage:lastpage:---
```{project-logo} _static/img/miniwobplusplus-text.png:alt: MiniWoB logo```
```{image} _static/img/showcase.gif:width: 100%:align: center```
The MiniWoB++ library contains a collection of over 100 **web interaction environments**,along with JavaScript and Python interfaces for programmatically interacting with them.The Python interface follows the [Gymnasium](https://gymnasium.farama.org/) APIand uses [Selenium WebDriver](https://www.selenium.dev/documentation/webdriver/)to perform actions on the web browser.
MiniWoB++ is an extension of the[OpenAI MiniWoB benchmark](http://proceedings.mlr.press/v70/shi17a/shi17a.pdf),and was introduced in the paper[Reinforcement Learning on Web Interfaces using Workflow-GuidedExploration](https://arxiv.org/abs/1802.08802).
The Gymnasium interface allows an agent to initialize and interact with a MiniWoB++ environment as follows:```pythonimport gymnasiumimport miniwobgymnasium.register_envs(miniwob)env = gymnasium.make('miniwob/click-test-2-v1', render_mode='human')try: observation, info = env.reset(seed=42) for _ in range(1000): action = policy(observation) # User-defined policy function observation, reward, terminated, truncated, info = env.step(action) if terminated: observation, info = env.reset()finally: env.close()```
```{toctree}:hidden::caption: Introduction
content/getting_startedcontent/basic_usage```
```{toctree}:hidden::caption: API
content/observation_spacecontent/action_spacecontent/reward```
```{toctree}:hidden::caption: Environments
content/viewingenvironments/listcontent/custom_environmentcontent/javascript_apicontent/demonstrations```
```{toctree}:hidden::caption: Development
Github <https://github.com/Farama-Foundation/miniwob-plusplus>Contribute to the Docs <https://github.com/Farama-Foundation/miniwob-plusplus/blob/master/docs/README.md>```12345sphinxmyst-parsergit+https://github.com/Farama-Foundation/Celshast#egg=furopandastabulate.gitattributes+5
README.md+3-1
miniwob-plusplus/.github/FUNDING.ymlAdded+1
miniwob-plusplus/.github/ISSUE_TEMPLATE/bug.mdAdded+27
miniwob-plusplus/.github/ISSUE_TEMPLATE/proposal.mdAdded+31
miniwob-plusplus/.github/ISSUE_TEMPLATE/question.mdAdded+12
miniwob-plusplus/.github/PULL_REQUEST_TEMPLATE.mdAdded+45
miniwob-plusplus/.github/stale.ymlAdded+62
miniwob-plusplus/.github/workflows/build-docs.ymlAdded+47
miniwob-plusplus/.github/workflows/build-publish.yamlAdded+68
miniwob-plusplus/.github/workflows/build.ymlAdded+21
miniwob-plusplus/.github/workflows/pre-commit.ymlAdded+24
miniwob-plusplus/.gitignoreAdded+143
miniwob-plusplus/.pre-commit-config.yamlAdded+54
miniwob-plusplus/CODE_OF_CONDUCT.rstAdded+67
miniwob-plusplus/CONTRIBUTING.mdAdded+28
miniwob-plusplus/LICENSEAdded+23
miniwob-plusplus/README.mdAdded+120
miniwob-plusplus/docs/.gitignoreAdded+3
miniwob-plusplus/docs/404.mdAdded+3
miniwob-plusplus/docs/README.mdAdded+36
miniwob-plusplus/docs/_scripts/gen_env_list.pyAdded+246
miniwob-plusplus/docs/_scripts/gen_mds.pyAdded+96
miniwob-plusplus/docs/_scripts/move_404.pyAdded+16
miniwob-plusplus/docs/_scripts/utils.pyAdded+51
miniwob-plusplus/docs/_static/img/custom-environment-1.pngAdded

miniwob-plusplus/docs/_static/img/example-usage-1.pngAdded

miniwob-plusplus/docs/_static/img/example-usage-2.pngAdded

miniwob-plusplus/docs/_static/img/favicon.pngAdded
miniwob-plusplus/docs/_static/img/miniwobplusplus-github.pngAdded

miniwob-plusplus/docs/_static/img/miniwobplusplus-text.pngAdded

Large File Pointer Details
- SHA256: 442ae1f39f59d01c233249030c35d9009dc9d7a412bd98ef9e95a9119ae90346
- Pointer size: 131 Bytes
- Size of remote file: 106 kB
miniwob-plusplus/docs/_static/img/miniwobplusplus-text.svgAdded
miniwob-plusplus/docs/_static/img/miniwobplusplus-white.svgAdded
miniwob-plusplus/docs/_static/img/miniwobplusplus.svgAdded
miniwob-plusplus/docs/_static/img/showcase-static.pngAdded

Large File Pointer Details
- SHA256: cf4c952e90ba4c43bfaffc3cbbe2bf981855198e24eb261cb2b075f4feb674db
- Pointer size: 131 Bytes
- Size of remote file: 278 kB
miniwob-plusplus/docs/_static/img/showcase.gifAdded

Large File Pointer Details
- SHA256: c04ac3920a659fa50a004aeb5500ea0d4ae043ceba29658972507c967323124b
- Pointer size: 132 Bytes
- Size of remote file: 3.12 MB
miniwob-plusplus/docs/_static/videos/miniwob.mp4Added+3
miniwob-plusplus/docs/conf.pyAdded+80
miniwob-plusplus/docs/content/action_space.mdAdded+171
miniwob-plusplus/docs/content/basic_usage.mdAdded+135
miniwob-plusplus/docs/content/custom_environment.mdAdded+164
miniwob-plusplus/docs/content/demonstrations.mdAdded+46
miniwob-plusplus/docs/content/getting_started.mdAdded+43
miniwob-plusplus/docs/content/javascript_api.mdAdded+53
miniwob-plusplus/docs/content/observation_space.mdAdded+98
miniwob-plusplus/docs/content/reward.mdAdded+28
miniwob-plusplus/docs/content/viewing.mdAdded+29
miniwob-plusplus/docs/environments/.gitkeepAdded
miniwob-plusplus/docs/index.mdAdded+80
miniwob-plusplus/docs/requirements.txtAdded+5