close

How can we use Selenium Webdriver in colab.research.google.com?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How can we use Selenium Webdriver in colab.research.google.com in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How can we use Selenium Webdriver in colab.research.google.com?

  1. How can we use Selenium Webdriver in colab.research.google.com?

    You can do it by installing the chromium webdriver and adjusting some options such that it does not crash in google colab:

  2. we use Selenium Webdriver in colab.research.google.com

    You can do it by installing the chromium webdriver and adjusting some options such that it does not crash in google colab:

Method 1


You can do it by installing the chromium webdriver and adjusting some options such that it does not crash in google colab:

!pip install selenium
!apt-get update # to update ubuntu to correctly run apt install
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver')
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
wd = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
wd.get("https://www.webite-url.com")

Method 2

this one worked in colab

!pip install selenium
!apt-get update 
!apt install chromium-chromedriver

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('chromedriver',chrome_options=chrome_options)

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read