Why did Selenium stop working today on Colab?

Viewed 106
1 Answers

The error relates to the typing library. I do not know exactly why this is happening and I hope someone has a better solution than mine, but editing the file that calls this library worked for me:

# Install Normal Selenium Stuff

!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')

## This edits the part of the file that gives the error:

with open('/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/virtual_authenticator.py', 'r') as file:
  
    # read a list of lines into data
    data = file.readlines()

data[21] = 'from typing_extensions import Literal\n'

with open('/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/virtual_authenticator.py', 'w') as file:

    file.writelines( data )

# Calls Selenium (It is important to edit the file before calling seleninum):

from selenium import webdriver

I know this is probably not the best solution, but it worked for me. I hope someone can come up with a better solution and explain why this is happening. Meanwhile, this will probably work for most people.

Related