Search code examples
pythonseleniumvps

Unable to open chromium browser in VPS with Selenium


I need to open chromium or chrome with selenium in Ubuntu 22 deployed in Digital Ocean VPS droplet. The issue is it doesnt open a chrome tab, the chromium and chromedriver are same version.This works fine in my localhost, with ubuntu 22.However, I was not able to run it when deployed in vps

  options = webdriver.ChromeOptions()
  options.add_extension(pluginfile)
  driver = webdriver.Chrome('chromedriver', options=options)

I tried several things including the suggestions here Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed

The error is

 (unknown error: DevToolsActivePort file doesn't exist)
 (The process started from chrome location /snap/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

As I already mentioned, this will work perfectly fine in localhost with same OS and chromedriver and chromium version.

Any idea how to make it work in a VPS?


Solution

  • After several attempt, I finally found the reason VPS doesn't allow selenium to open the browser.It only works in headless mode, which doesn't fit my requirements since I have plugins and headless mode will not run with plugins