Firefox can't load the profile while working with selenium webdriver

28 views Asked by At

I am a newbie in Docker world. Yesterday I tried to run a script that just finds a specific item in a list then clicks on it and then gets it's class to check if 'active' class was there. Script itself on my local machine works just fine. But when I tried to run it in a Docker container using Dockerfile, I encountered several problems and somehow made it work.

Now I tried to use docker compose to make building and running a container easier but encountered THIS problem. This keeps happening even when I use Dockerfile.

Docker Desktop: v4.27.2

Docker image: selenium/standalone-firefox:latest

Full stacktrace:

Traceback (most recent call last):
  File "/app/main.py", line 46, in <module>
    main()
  File "/app/main.py", line 5, in main
    driver = webdriver.Firefox()
  File "/home/seluser/.local/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__
    executor = ExtensionConnection("127.0.0.1", self.profile,
  File "/home/seluser/.local/lib/python3.10/site-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__        
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "/home/seluser/.local/lib/python3.10/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser        
    self._wait_until_connectable(timeout=timeout)
  File "/home/seluser/.local/lib/python3.10/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 103, in _wait_until_connectable
    raise WebDriverException("Can't load the profile. Profile "
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /tmp/tmppod0_4mw If you specified a log_file in the FirefoxBinary constructor, check it for details.

Dockerfile

FROM selenium/standalone-firefox:latest

WORKDIR /app

ENV MOZ_HEADLESS=1

CMD ["python3", "main.py"]

compose.yml

version: '3'

services:
  selenium:
    build: .
    volumes: 
      - ./main.py:/app/main.py:ro

Tried ubuntu/20.04; Did a full system update, installed firefox, installed selenium and then tried to run my script, same error.

Searched for how to 'create' a firefox profile, load existing firefox profile and so on, nothing helped. What do i do?

0

There are 0 answers