CircleCI Docker Firefox: How can I run Firefox in Docker in CircleCI?

Viewed 16

I have this setup below and I'm getting an error in CircleCI. :( :/

OSError: [Errno 8] Exec format error: '/home/circleci/project/drivers/geckodriver'

If it's because the OS is not supported, what is the driver for Docker (running in CircleCI)? Or how do we setup Firefox in Docker? I only have CircleCI and PyCharm setup and my local geckodriver is inside /usr/bin/geckodriver. I tried following some tutorials but got even more confused :/

config.yml

version: 2.1

orbs:
  python: circleci/python@1.5.0

jobs:
  jobTitle:
    docker:
      - image: cimg/python:3.10.2
    steps:
      - checkout
      - python/install-packages:
          pkg-manager: pip
      - run:
          name: Run tests
          command: behave

workflows:
  featureFiles:
    jobs:
      -   jobTitle

and also added the requirements.txt

async-generator>=1.10
attrs>=2.1.0
behave>=1.2.6
certifi>=2022.6.15
decorator>=5.1.1
et-xmlfile>=1.1.0
h11>=0.13.0
numpy>= 1.23.3
openpyxl>=3.0.10
outcome>=1.2.0
parse>=1.19.0
parse-type>=0.6.0
pip>=21.3.1
PySocks>=1.7.1
pytz>=2022.2.1
selenium>=4.4.3
self>=2020.12.3
setuptools>=60.2.0
six>=1.16.0
sniffio>=1.2.0
sortedcontainers>=2.4.0
trio>=0.21.0
trio-websocket>=0.9.2
urllib3>=1.26.12
wheel>=0.37.1
wsproto>=1.2.0

but when I tried running it in CircleCI it's giving me this error:

enter image description here

Here is the start of my code (all of the required imports are imported)

download_path = os.path.abspath("./downloads")
firefoxDriver = os.path.abspath("./drivers/geckodriver")
options = Options()
baseURL = "https://create-develop.quipper.net/"

@given("user has logged in with Administrator role")
def step_impl(context):
    # to assign downloads folder within the project
    options.set_preference("browser.download.folderList", 2)
    options.set_preference("browser.download.manager.showWhenStarting", False)
    options.set_preference("browser.download.dir", download_path)
    options.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv")

    context.driver = webdriver.Firefox(
        options=options,
        executable_path=firefoxDriver
    )

Here is my project structure:

enter image description here

Update as of Sept 15

I have updated my driver to Linux geckodriver. I got now an error

 selenium.common.exceptions.SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

enter image description here

means I don't have Firefox installed in my Docker. How do I install it? Do I have to make a Dockerfile for this?

0 Answers
Related