Skip to content

jakob-bagterp/browserist

Repository files navigation

Latest version Python 3.10 | 3.11 | 3.12+ Apache 2.0 license Codecov CodeQL Test Downloads

πŸ‘©β€πŸ’» Browserist – Python Extension for Selenium πŸ‘¨β€πŸ’»

browserist

  1. The belief that web browsers account for differences in websites or web applications in all of their ability and that a particular web browser is superior to others.
  2. Discrimination or prejudice based on web browser.

Despite the urban definition, Browserist is a Python extension of the Selenium web driver that makes it even easier to use different browsers for testing and automation.

Main Features

With Browserist as an extension to Selenium, you get:

  • Improved stability and speed
  • Simple syntax and less code
  • Hassle-free setup across browsers: Chrome, Firefox, Edge, Safari, Internet Explorer
  • Extensive framework of functions that makes browser automation easy
  • Efficient development workflow with IntelliSense and type hints

How to Install

Ready to try? With PyPI:

pip install browserist

Or with Homebrew:

brew tap jakob-bagterp/browserist
brew install browserist

Find more installation details here.

Getting Started

You're now ready to go:

from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.wait.seconds(5)

Improved Stability and Less Code

Browserist improves stability with less code compared to standard use of Selenium. As browsers need time to render web pages, especially single-page applications, Selenium is often used with explicit timeouts:

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

driver.get("https://example.com")
driver.implicitly_wait(3)
search_box = driver.find_element(By.XPATH, "//xpath/to/input")
search_button = driver.find_element(By.XPATH, "//xpath/to/button")
search_box.send_keys("Lorem ipsum")
search_button.click()
driver.quit()

Browserist does the same with less and cleaner code, yet also with increased stability and without explicit/implicit waits:

from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.input.value("//xpath/to/input", "Lorem ipsum")
    browser.click.button("//xpath/to/button")

Documentation

Find tutorials, code examples, list of all methods and much more here.

Thank You for Supporting

Donate

This module is free to use. And if you like it, feel free to sponsor the project.

Contribute

If you have suggestions or changes to the module, feel free to add to the code and create a pull request.

Report Bugs

Report bugs and issues here.