Browserist Compared to Selenium#
Browserist is an extension to the Selenium that makes web scraping and browser automation even easier. Since Browserist only uses XPath expressions to target web elements, be aware of the differences in syntax.
Examples of Syntax Differences#
Get Element by ID#
Get Element by Class#
Get Element by XPath#
Why Use XPath?#
While Selenium offers several methods to target web elements – for instance By.ID
, By.CLASS_NAME
, etc. – Browserist solely uses XPath to locate web elements in the DOM of a web page. Why so?
XPath is a simple, yet powerful tool similar to a Swiss Army knife that gets the job done with compact code. And so you only need to master a single vocabulary instead of multiple By
class options and importing extra modules from Selenium.