I have already read a couple of threads about this problem but none of them really helped me so here goes. I am trying to use selenium webdriver on google colab. i had some problems installing it but finally with the code below, i was able to install it:
!pip install selenium
!apt-get update
!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")
however, now when i run this two lines of codes:
from selenium import webdriver
driver = webdriver.Chrome()
this is the error I get:
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
headless
and then it can run on server. (Server without monitor is called "headless" because monitor looks like it head)headless
in everywebdriver.Chrome()
- which runs new browser.webdriver.Chrome('chromedriver',chrome_options=chrome_options)
. You have to usechrome_options
with--headless
in everywebdriver.Chrome()