I've desperetaly tried to set a pytest
pipeline CI/CD for my personal projet hosted by gitlab.
I tried to set up a simple project with two basic files:
file test_core.py
, witout any other dependencies for the sake of simplicity:
# coding: utf-8
# !/usr/bin/python3import pytest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Optionsdef test_basic_headless_selenium_example():"""Test selenium installation by opening python website.(inspired by https://selenium-python.readthedocs.io/getting-started.html)"""opts = Options()opts.headless = Truedriver = webdriver.Firefox(options=opts)driver.get("http://www.python.org")driver.close()
File .gitlab-ci.yml
, for CI/CD automatic tests:
stages:- testspytest:python3.7:image: python:3.7stage: testsservices:- selenium/standalone-firefox:latestscript:# - apt-get update && apt-get upgrade --assume-yes- wget -O ~/FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64"- tar xjf ~/FirefoxSetup.tar.bz2 -C /opt/- ln -s /opt/firefox/firefox /usr/lib/firefox- export PATH=$PATH:/opt/firefox/- wget -O ~/geckodriver.tar.gz "https://github.com/mozilla/geckodriver/releases/download/v0.28.0/geckodriver-v0.28.0-linux64.tar.gz"- tar -zxvf ~/geckodriver.tar.gz -C /opt/- export PATH=$PATH:/opt/- pip install selenium pytest- pytest
On my laptop, the pytest
command works fine 100% of time.
When I push a commit to gitlab, I deseperately get errors:
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 255
/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py:242: WebDriverException
=========================== short test summary info ============================
FAILED test_selenium.py::test_basic_headless_selenium_example - selenium.comm...
============================== 1 failed in 1.29s ===============================
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
I've created a simple project: https://gitlab.com/OlivierLuG/selenium_firefox that reproduce this example. The failed pipeline can be directely found here : https://gitlab.com/OlivierLuG/selenium_firefox/-/pipelines/225711127
Does anybody have a clue how to fix this error ?