Skip to main content

robotframework-browserpom

PyPI version

📖 Documentation: https://hasanalpzengin.github.io/robotframework-browserpom

robotframework-browserpom is a small extension for robotframework-browser that makes it easy to define Page Object Models (POMs) for browser-based Robot Framework tests. It provides helpers and conventions for building readable, reusable page objects and wiring them into Robot tests.

Features

  • Integration with Robot Framework Browser: Seamlessly integrates with the robotframework-browser library.
  • Page Object Model Support: Simplifies the creation and management of Page Objects in browser-based test automation.
  • Enhanced Readability: Improves the maintainability of test automation by promoting a clean separation between test actions and page element interactions.

Installation

To install robotframework-browserpom use poetry:

poetry add robotframework-browserpom

For development / contributing:

poetry install

Dependencies

  • Python 3.12 or above
  • robotframework (>=7.1.0)
  • robotframework-browser (>=18.0.0)

Development dependencies commonly used by contributors:

  • pytest (testing)
  • black (formatting)
  • isort (import sorting)
  • flake8 / pylint (linting)
  • mypy (static type checking)
  • coverage (coverage reports)

Quick usage

Create Page Objects as Python classes and use them from Robot Framework tests. Example:

class MainPage(PageObject):
  PAGE_TITLE = "MainPage"
  PAGE_URL = "/index.html"

  tile = Tile("//li")
  search_bar: UIObject = UIObject("//input[@id='searchBar']")

  @keyword
  def enter_search(self, search):
    self.browser.type_text(str(self.search_bar), search)

Then import the POM library in Robot tests:

*** Settings ***
Library   BrowserPOM
Library   demo/MainPage.py   AS  MainPage

Test Setup    Browser.Open Browser    https://automationbookstore.dev     headless=True

robotframework-browserpom

PyPI version

📖 Documentation: https://hasanalpzengin.github.io/robotframework-browserpom

robotframework-browserpom is a small extension for robotframework-browser that makes it easy to define Page Object Models (POMs) for browser-based Robot Framework tests. It provides helpers and conventions for building readable, reusable page objects and wiring them into Robot tests.

Editor / linter integration: the variables problem

Many editors and language servers (e.g., RobotCode / Robot Framework IntelliSense) warn when variables referenced by Robot Framework tests are not defined. The common workaround is to maintain a variables.py that imports or defines the POM libraries so the IDE recognizes them. Maintaining that file by hand is tedious — every time you add a new Page Object module you must update the variables file.

To avoid this manual step, BrowserPOM ships a tiny utility module that statically scans a Python package/folder for Page Object classes and returns dummy variable values for them. Because it uses Python's ast module no project code is executed — it's safe and fast.

The pom_stubs helper

BrowserPOM.pom_stubs.get_variables(base_path) will scan base_path for .py modules and return a mapping of class names for classes that inherit from PageObject. The returned mapping can be used as a Robot variables file source (via robot.toml or the --variablefile CLI option).

Example behavior:

from BrowserPOM import pom_stubs

# returns something like {"MainPage": "MainPage", "Tile": "Tile"}
pom_stubs.get_variables("./demo/")

This is intentionally minimal: the actual variable values are irrelevant for editor intellisense — they just need to exist so the linter stops complaining.

If you prefer, the helper may be extended to return more information (file stems, class attributes, dummy instances, etc.).

Usage via robot.toml

You can register the helper as a variable-file in robot.toml so your editor or Robot runner picks it up automatically. Example robot.toml:

variable-files = ["BrowserPOM.pom_stubs:demo/"]

That tells the Robot tools to call BrowserPOM.pom_stubs.get_variables("demo/") and use the returned mapping as variables for the project. The argument is the path to the folder containing your POM modules (relative to the project root).

Alternatively you can pass the helper directly on the Robot CLI:

# optional example shown for documentation only
robot --variablefile BrowserPOM.pom_stubs:demo/ tests/

Example Page Object

Define your page objects as normal — inherit from PageObject and add your members and keywords:

class MainPage(PageObject):
    PAGE_TITLE = "MainPage"
    PAGE_URL = "/index.html"

    tile = Tile("//li")
    search_bar: UIObject = UIObject("//input[@id='searchBar']")

    @keyword
    def enter_search(self, search):
        self.browser.type_text(str(self.search_bar), search)

    def get_tile_count(self):
        return self.browser.get_element_count(str(self.tile))

Notes and limitations

  • The helper uses ast and does not import or execute any project code.
  • It currently includes classes that inherit from PageObject (best-effort detection for dotted or parametrized base expressions).
  • The returned variable values are dummy placeholders intended for editor tooling only. If you need richer stubs (e.g., mapping to file stems or class metadata) we can extend the helper.

Contributing

Contributions are welcome; please follow the repository coding guidelines and add tests for new behavior.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework_browserpom-0.6.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robotframework_browserpom-0.6.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file robotframework_browserpom-0.6.0.tar.gz.

File metadata

  • Download URL: robotframework_browserpom-0.6.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for robotframework_browserpom-0.6.0.tar.gz
Algorithm Hash digest
SHA256 bea436de9012db813818c41108c0589c5bb6206c1c3a7753f8b106c9fdf31cd6
MD5 74dd2b8a681f2ec513fb0a2e57e281b9
BLAKE2b-256 da305509f1f90d1933ff8899cae29ca206a75b388a3a7cac8fe51c3cff5d5ed3

See more details on using hashes here.

File details

Details for the file robotframework_browserpom-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: robotframework_browserpom-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for robotframework_browserpom-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c5ae5c3ef8ffef7b94e35b5ca5ff4b76c7f752d78a30fc653692519f8667fc5
MD5 14944296086aeba1d5380662cc597715
BLAKE2b-256 0b80c4e2860a9a60d9e5296d59f60b46725550802a054033111c185847d76d2c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.7.0

2 files

0.6.1

2 files

This release

0.6.0 This release

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.10

2 files

0.4.9

2 files

0.4.8

2 files

0.4.7

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.0

2 files

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