Errors with Python Selenium in Flask App (WebDriverException: not connected to DevTools) deployed using Docker

philbertsheaTRIAL

a year ago

Hi, I've been trying to deploy a simple flask app involving Selenium on Python.

I've used Dockerfile to install the latest stable chrome, chromedriver and related dependencies. However, though deployment has been successful, it keeps returning this exception:

selenium.common.exceptions.WebDriverException: Message: disconnected: not connected to DevTools

Jun 22 12:58:11

(failed to check if window was closed: disconnected: not connected to DevTools)

Does anyone have experience with selenium exceptions? Thank you very much in advance.

4 Replies

philbertsheaTRIAL

a year ago

Github Repo: philbertshea/poems_api (github.com)

Thank you very much in advance. I'm not experienced in Docker so not sure what went wrong.I did try the WebDriverManager but it didn't seem to work.


a year ago

I would highly recommend using Browserless, using it means you don't have to install Chrome and all of its needed dependencies into your container or deal with any of the issues involved in that, and this will significantly speed up both the build and the publishing stage.

Browserless template here - https://railway.app/template/browserless

And here's an example repo that shows you how to use Browserless with Selenium - https://github.com/brody192/selenium-example-python


philbertsheaTRIAL

a year ago

Hi,

Thank you for your prompt reply.

I learnt that browserless is a paid service. I'm currently trying out a hobby project and would like a simple solution that works for small-scale deployment purposes.

Thank you anyway for the suggestion.


a year ago

You are not the first to reply back to me telling me it's a paid service, I am aware of that, but I am proposing that you self host it on Railway, it's free to self host for non-commercial use.


Errors with Python Selenium in Flask App (WebDriverException: not connected to DevTools) deployed using Docker - Railway Help Station