avatarShan Yi Tan
# Summary

The web content outlines a concise four-step process for installing Selenium and running it successfully in Jupyter Lab, with an additional step for testing the installation.

# Abstract

The article provides a straightforward guide for setting up Selenium in Jupyter Lab, which includes installing Selenium via pip, downloading the appropriate WebDriver for the user's browser, extracting and placing the WebDriver executable in the system's PATH, and verifying the installation with a test that opens and closes Facebook in a browser session. The guide emphasizes ease, with only four main steps required, and offers a code snippet to help users locate their PATH if unknown. It concludes with a simple test to confirm that Selenium has been installed correctly.

# Opinions

- The guide assumes the process is user-friendly, indicated by the phrase "Only 4 steps."
- The author provides a direct link to download the WebDriver, showing a commitment to user convenience.
- The inclusion of a code snippet to find the system's PATH suggests the author anticipates potential user difficulties and proactively addresses them.
- The choice to use Facebook as a test site implies a familiar example for most users, which can enhance the user's confidence in following the instructions.
- The guide is browser-agnostic, advising users to select the WebDriver based on their preferred browser, thus catering to a wider audience.

How to install Selenium and run it successfully via Jupyter Lab

Only 4 steps

  1. Open your Jupyter Lab and run the code below.
!pip install selenium

2. Download the zipped file of WebDriver here. Choose the one based on the browser that you are using.

3. Extract the downloaded file and copy-paste the .exe file to your PATH.

4. Don’t know where’s your PATH? Run the code on Jupyter Lab to get it and paste the file into the directory you just found out.

import os
import sys
os.path.dirname(sys.executable)

5. After you paste your file into the PATH, test whether it works using code below.

from time import sleep
from selenium import webdriver
# this is tested on Firefox or you can use "webdriver.Chrome()"
browser = webdriver.Firefox()
browser.get(‘https://www.facebook.com/')
sleep(5)
browser.close()

7. If you see the Firefox browser opens facebook.com and closes it after 5 seconds. Then the installation is done!

Selenium
Selenium Webdriver
Jupyterlab
Jupyter Notebook
Web Scraping
Recommended from ReadMedium