Browserist – Python Extension for Selenium 👨💻#
Introduction#
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
Ready to try? Let's get started.
Difference from Selenium#
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:
Browserist does the same with less and cleaner code, yet also with increased stability and without explicit/implicit waits:
With Browserist | |
---|---|
Why Avoid Explicit or Implicit Waits?#
As you can't click a button that's not ready in the DOM, Browserist simply checks if elements are ready before interacting with them. This makes the code more stable and less prone to errors.
Sweet Spot of Browser Automation#
You don't want to be too fast nor too slow when automating a browser. You're simply dependant on too many factors that are beyond your control: internet speed, server response time, etc. The sweet spot is to be just right:
Timing | Consequence | Code | Description |
---|---|---|---|
Too short | Code breaks | time.sleep(1) | Wait for 1 second, hoping that an element is ready within a fixed amount of time. |
Just right | Stable and fast | wait.for_element() | Browserist checks if an element is ready before interacting with it. |
Too long | Slow | time.sleep(10) | Wait for 10 seconds, just to be sure an element is ready. |
Ready to try? Let's get started.