Overview of Helium for web automation
masterSelenium-python, providing a simpler and more intuitive API for automating websites while leveraging the underlying power of Selenium.repository·master·Indexed 27 days ago
https://github.com/mherrmann/heliumA high-level Python library for web automation that wraps Selenium. Helium allows developers to interact with web elements using user-visible labels instead of complex HTML selectors like XPaths or CSS selectors. It provides a simplified API for browser interaction, explicit waits via wait_until(), and the ability to mix Helium functions with standard Selenium API calls.
Selenium-python, providing a simpler and more intuitive API for automating websites while leveraging the underlying power of Selenium.After installation, you can verify that Helium is ready to use by importing it in a Python shell:
from helium import *To use Helium, you need Python 3 and either Chrome or Firefox installed. It is recommended to use a virtual environment to manage dependencies.
Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activatepython3 -m venv venv
call venv\scripts\activate.batInstall Helium using pip:
python -m pip install heliumpython -m pip install heliumAll public Helium functions are available directly in the helium module. The most common way to use the library is to import everything into the local namespace.
from helium import *To build the Helium documentation locally, ensure you have python and pip installed. Run the following commands from the project root to install the necessary development dependencies and generate the HTML documentation.
The resulting documentation will be located in the docs/_build/ directory. You can view it by opening docs/_build/index.html in your web browser.
pip install -Ur requirements/docs.txt
make -C docs/ htmlIt is recommended to use a virtual environment to keep your Helium installation isolated. Follow these steps:
Create the virtual environment:
python3 -m venv venvActivate the environment:
source venv/bin/activatecall venv\Scripts\activate.batInstall Helium inside the activated environment:
python -m pip install heliumpython3 -m venv venv
# On Mac/Linux:
source venv/bin/activate
# On Windows:
call venv\Scripts\activate.bat
python -m pip install heliumTo install Helium, ensure you have Python 3 and either Chrome or Firefox installed on your system. You can install the package directly using pip:
pip install heliumConfig class.A typical Helium script involves starting a browser, navigating to a URL, typing text, clicking elements, and closing the browser.
from helium import *
start_chrome('google.com')
write('helium selenium github')
press(ENTER)
click('mherrmann/helium')
go_to('github.com/login')
write('username', into='Username')
write('password', into='Password')
click('Sign in')
kill_browser()Helium is a high-level wrapper around Selenium. Because it forwards calls to Selenium, you can freely mix Helium functions with standard Selenium API calls using the driver instance returned by Helium functions like start_chrome() or start_firefox().
# A Helium function:
driver = start_chrome()
# A Selenium API:
driver.execute_script("alert('Hi!');")WebDriver using get_driver() or set a custom one with set_driver(). To convert a Helium element into a Selenium WebElement, use its .web_element property.You can launch Chrome or Firefox using start_chrome() or start_firefox(). You can optionally pass a URL as the first argument to open immediately. To run the browser without a visible window (useful for automated tasks), set headless=True.
start_chrome('google.com')
start_chrome(headless=True)
start_firefox('google.com', headless=True)