Question

Running selenium on a droplet

I am trying to run selenium webdriver on my droplet, and after days of unsuccessful attempts, I need some help. Here’s what I have done:

Hooked up a display:

from pyvirtualdisplay import Display from selenium import webdriver display = Display(visible=0, size=(1024, 768)) display.start()

Here’s where it chokes for Chrome:

b = webdriver.Chrome() #doesn’t choke yet, but definitely hangs for longer than normal… b <selenium.webdriver.chrome.webdriver.WebDriver (session=“7725d000781011a8e713a7fd722361b4”)> b.get(‘https://www.google.com’) #and there it is…

selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.executionContextCreated has invalid ‘context’: {“auxData”:{“frameId”:“1342.1”,“isDefault”:true},“id”:1,“name”:“”,“origin”:“://”} (Session info: chrome=55.0.2883.87) (Driver info: chromedriver=2.9.248304,platform=Linux 4.4.0-59-generic x86_64)

And here’s where it chokes for Firefox:

b = webdriver.Firefox() selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 2

I have tried at least 4 versions of different chrome drivers. I have selenium working on my personal box (I use Chrome) with this similar setup, but I don’t use/need the display. I am running the cheap droplet, 512mb, 5$, but I resized it to 4 GB of memory and it still fails, so its not there?

Thank you very much.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I wasn’t playing with Selenium a lot, but AFAIK, it does require you GUI, to run browser. Error doesn’t appear to share a lot information, but if you don’t have any UI on server that can be a problem.

In case this is a problem, you can checkout headless mode and headless browser. It let’s you use browser from a CLI. There is no tutorial here, but I found one Medium article - Running Selenium WebDriver tests using Firefox headless mode on Ubuntu. Also, you can play around VNC and setup GUI on the server, that way.