BrowserGym
raw JSON → 0.14.3 verified Mon Apr 27 auth: no python
BrowserGym is a Gymnasium-compatible environment for web task automation in Chromium. It provides a standardized interface for training and evaluating AI agents on web tasks, supporting both human demonstrations and automated interactions. Version 0.14.3 requires Python >3.10, with frequent releases.
pip install browsergym Common errors
error ModuleNotFoundError: No module named 'browsergym' ↓
cause BrowserGym is not installed, or the installation is incomplete (e.g., missing optional dependencies like playwright).
fix
Ensure install with
pip install browsergym[all] to include all dependencies, or separately install playwright: pip install playwright && playwright install chromium. error gymnasium.error.UnregisteredTask: Task browsergym/miniwob.click-test is not registered ↓
cause The task string uses the old prefix without the trailing dot, or the MiniWoB tasks are not included in the installation.
fix
Use the correct task ID with trailing dot: 'browsergym/miniwob.click-test'. If still failing, install browsergym with the miniwob extra:
pip install browsergym[miniwob]. Warnings
breaking In version 0.14.0, the observation space changed from a dict with 'text' and 'image' keys to a Gymnaxium Dict with additional fields. Old code that directly accesses obs['text'] or obs['image'] may break. ↓
fix Use obs['observation']['text'] and obs['observation']['image'] or check the updated observation space structure.
deprecated The 'browsergym/miniwob' task prefix was renamed to 'browsergym/miniwob.' (with a trailing dot) in version 0.13.0. The old prefix is deprecated and will be removed. ↓
fix Use 'browsergym/miniwob.' prefix (e.g., 'browsergym/miniwob.click-test').
gotcha The 'headless' argument in make() defaults to False. When running in CI or non-interactive environments, the browser may hang. Always set headless=True for automated testing. ↓
fix Call make(task, headless=True).
Imports
- make wrong
import browsergymcorrectfrom browsergym import make
Quickstart
from browsergym import make
import gymnasium as gym
task = 'browsergym/miniwob.click-test'
env = make(task, headless=True)
obs, info = env.reset()
# Execute a simple action (e.g., click at coordinates)
action = {
"action": "click",
"x": 100,
"y": 100
}
obs, reward, terminated, truncated, info = env.step(action)
print(f"Reward: {reward}")
env.close()