Search code examples
pythonselenium-webdriverselenium-chromedrivergoogle-colaboratory

Does Google Colab come pre-installed with ChromeDriver in the backend?


I am using Google Colab for the first time and exploring how to use it with Selenium (v4.11.2). I was able to run the code below without installing ChromeDriver, but every example I've come across for using Selenium in Google Colab requires that it be installed beforehand. My understanding is that ChromeDriver is necessary for Selenium to communicate with Chrome, so I'm curious to know if ChromeDriver comes preinstalled with Google Colab. If so, where exactly is it being stored?

I was expecting an error since I did not install ChromeDriver prior to running the code below, but it worked anyway and I would like to know why.

!apt-get update 
!pip3 install selenium
 
from selenium import webdriver 

# chrome runtime flags 
options = webdriver.ChromeOptions() 
options.add_argument("--headless=new") 
options.add_argument("--no-sandbox") 

# start session 
driver = webdriver.Chrome(options=options) 

# load url 
driver.get("http://selenium.dev") 

# get page title 
title = driver.title 

print(title) 

# quits session 
driver.quit() 

Solution

  • If you use selenium version 4.6.0 or above, then selenium has an in-built tool known as Selenium Manager which will download and manage the browser drivers. No need of manually downloading chromedriver.exe and setting the path in your code. All is done and managed by selenium internally.

    For more info refer below links: