The selenium Package
The selenium
package provides capabilities for automating the process of browsing the web and interacting with elements on any web page.
Reference:
Prerequisites
Before proceeding, we need to install a special kind of web browser called a "web driver" which the Selenium package will be able to control.
There are options to use a Firefox-based browser, but the professor recommends you install the Google Chrome-based "Chromedriver". Identify the path to where you have installed chromedriver
. We'll need this value later (see CHROMEDRIVER_PATH
variable below in the "Usage" example).
Installation
After installing a web driver, install the package using Pip, as necessary:
Usage
First, initialize a new driver object. You can do so in the default mode, which will open a browser window for you to view, or in "headless" mode, which will not open a browser window.
After initializing a driver, use it to visit and interact with web pages:
Resulting screenshots:
Last updated