Answer the question
In order to leave comments, you need to log in
How to run selenium from python-flask application?
Greetings!
I broke my head over the following problem:
I use Pyhon+Flask+Gunicorn+Nginx+Selenium.
If you run Selenium tests directly from the console, then everything works fine, but when trying to run testing inside the Flask application, errors begin, in particular, Selenium does not see the geckodriver if it is located directly in the tests folder inside the Flask application, I specify directly:
driver = webdriver.Firefox("/user/test/flask_app/app_files/selenuim_test", capabilities=firefox_capabilities, options=options)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
shutil.Error: [('/user/test/flask_app/flask_app.sock', '/tmp/tmp1vkuyshz/webdriver-py-profilecopy/run/flask_app.sock'', "[Errno 6] No such device or address: '/user/test/flask_app/flask_app.sock'")
Answer the question
In order to leave comments, you need to log in
Finally found the answer suggested on another site.
in Gunicorn .service file Environment=
must be added at the end /env/bin
:/usr/bin:/bin
as shown in the example:
Environment="PATH=/home/username/env/bin:/usr/bin:/bin"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question