I'm having trouble getting my python Selenium running in github actions.
I have been using Circle CI for the past year, but recently began migrating over to github actions.
For Circle CI to run selenium in a chrome browser, I had the following lines in my config.yml:
docker:
# includes chrome browser for selenium testing
- image: circleci/python:3.7.4-browsers
and there didn't seem to be a need to install a chromedriver.
I am using the following in my githubs action .yml file:
jobs:
build:
runs-on: ubuntu-latest
services:
selenium:
image: selenium/standalone-chrome
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install
- name: Prepare Selenium
# https://github.com/marketplace/actions/setup-chromedriver
uses: nanasess/setup-chromedriver@master
- name: Launch browser
run: |
google-chrome --version
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional, disables headless mode
- name: Run tests
run: pipenv run python manage.py test functional_tests.tests.test_selenium.test_exams -v 2
But I get the following error when in my python code I try to run:
from selenium import webdriver
driver = webdriver.Chrome()
File "/home/runner/.local/share/virtualenvs/lang-EMCZ4oUT/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "/home/runner/.local/share/virtualenvs/lang-EMCZ4oUT/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/home/runner/.local/share/virtualenvs/lang-EMCZ4oUT/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/runner/.local/share/virtualenvs/lang-EMCZ4oUT/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/runner/.local/share/virtualenvs/lang-EMCZ4oUT/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
From what I can read online, I should need just the uses: nanasess/setup-chromedriver@master
and shouldn't need image: selenium/standalone-chrome
, but switching either in or out doesn't make any difference, the python tests still cannot find chrome browser.
Am I supposed to set up a port to listen to?