gitmyhub

helium

Python ★ 8.3k updated 18d ago

Lighter web automation with Python

A Python library that simplifies browser automation by letting you click buttons and fill forms using visible text labels instead of HTML IDs or XPath, making Selenium scripts 30, 50% shorter to write.

PythonSeleniumChromeFirefoxsetup: easycomplexity 2/5

Helium is a Python library for automating web browsers. It sits on top of Selenium, the standard tool for browser automation, but provides a much simpler interface. Where Selenium requires you to locate page elements using technical identifiers like HTML element IDs, XPath expressions, or CSS selectors, Helium lets you refer to things by the text a user actually sees on the screen. For example, you can click a button by writing click("Submit") rather than hunting for an XPath to that button.

The practical result is that Helium scripts tend to be 30 to 50 percent shorter than the equivalent Selenium scripts. Because Helium is just a wrapper around Selenium, you can mix the two freely in the same script. Anything Helium does not cover, you can do with the underlying Selenium driver.

Beyond the simpler API, Helium also removes some of Selenium's common pain points. It handles iFrames transparently, so you do not need to "switch to" a nested frame before interacting with elements inside it. It manages popup windows automatically, focusing them as they open and returning to the previous window when they close. It also adds sensible implicit waits: rather than failing immediately if an element has not yet loaded, Helium waits up to 10 seconds by default. For explicit waits, the API is much cleaner than Selenium's verbose alternative.

Installation requires Python 3 and Chrome or Firefox. Install with pip (pip install helium). The repository includes a cheatsheet and links to full documentation at helium.readthedocs.io.

The project was originally built in 2013 for a startup and open-sourced in 2019 when that company closed. The author notes limited time for maintenance and does not regularly respond to issues, but does review and merge pull requests. The name Helium was chosen because, like Selenium, it is a chemical element, and it is lighter.

Where it fits