🚀 Limited Time: 20% off on all courses Enroll Now
Bengaluru •

Installing Selenium WebDriver & Automating with Python on VS Code (Step-by-Step)

By BBSEdTech Editorial Published: Aug 15, 2025 Updated: Aug 16, 2025 12 min read Category: Python • Selenium
Install Selenium WebDriver & Automate with Python on VS Code - BBSEdTech

Introduction

This tutorial gets you from zero to your first Selenium run using Python + VS Code. We’ll install packages, show the automatic driver method (easy) and the manual driver method (for locked-down environments).

Prerequisites

  • Windows/Mac/Linux
  • Python 3.8+ recommended
  • Google Chrome (or Edge/Firefox/Safari)

Install Python

  1. Download from python.org.
  2. Windows: Tick “Add Python to PATH”.
python --version
pip --version

Setup VS Code

  1. Install VS Code and the “Python” extension.
  2. Create a folder and open it in VS Code.
  3. Open a terminal: View → Terminal.

Install Selenium

pip install selenium webdriver-manager

Option A: Automatic Driver (Recommended)

Tip: webdriver-manager automatically downloads a compatible driver at runtime.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
import time

options = Options()
options.add_argument("--start-maximized")

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://www.google.com")
time.sleep(2)

box = driver.find_element(By.NAME, "q")
box.send_keys("BBSEdTech")
box.submit()

time.sleep(3)
driver.quit()
Firefox/Edge with webdriver-manager
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()))
driver.get("https://www.example.com")
driver.quit()
from selenium import webdriver
from selenium.webdriver.edge.service import Service
from webdriver_manager.microsoft import EdgeChromiumDriverManager

driver = webdriver.Edge(service=Service(EdgeChromiumDriverManager().install()))
driver.get("https://www.example.com")
driver.quit()

Option B: Manual Browser Driver Setup

Download the matching driver (ChromeDriver/GeckoDriver/EdgeDriver) and point Selenium to its path.

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time

options = Options()
options.add_argument("--start-maximized")

chromedriver_path = r"C:\tools\drivers\chromedriver.exe"  # Update this
driver = webdriver.Chrome(service=Service(chromedriver_path), options=options)

driver.get("https://www.google.com")
time.sleep(2)
driver.find_element(By.NAME, "q").send_keys("BBSEdTech")
driver.find_element(By.NAME, "q").submit()
time.sleep(3)
driver.quit()
Manual: Firefox & Edge examples
from selenium import webdriver
from selenium.webdriver.firefox.service import Service

gecko_path = r"C:\tools\drivers\geckodriver.exe"  # Update path
driver = webdriver.Firefox(service=Service(gecko_path))
driver.get("https://www.example.com")
driver.quit()
from selenium import webdriver
from selenium.webdriver.edge.service import Service

msedge_path = r"C:\tools\drivers\msedgedriver.exe"  # Update path
driver = webdriver.Edge(service=Service(msedge_path))
driver.get("https://www.example.com")
driver.quit()

Your First Script

Run either the automatic or manual sample above. For CI or containers, prefer manual with pinned versions.

FAQ & Fixes

ModuleNotFoundError: selenium

Install into the active interpreter: pip install selenium. Use the VS Code interpreter switcher on the status bar.

NoSuchDriverException

Let webdriver-manager handle versioning or ensure ChromeDriver matches your Chrome major version.

Run headless

options.add_argument("--headless=new") before creating the driver.

Safari on macOS

Enable “Develop → Allow Remote Automation” and use webdriver.Safari(); no external binary needed.