0

How to run Python Selenium with Chrome GUI on Ubuntu Container with Browserfull (NOT Browserless) on Docker on a WIndows 10 host PC?

I want to run Chrome Browser with Selenium Python from my Ubuntu container on my Windows 10 Host PC. I DO NOT want to run headless browser.

I want to change my Dockerfile to use Chrome browser with Selenium Python.

I have tried downloading Chromedriver, but it is failing.

I have tried out all the other suggestions from Google and Stackoverflow, but nothing is working. Any suggestions?

The following is my Dockerfile:

FROM ubuntu:latest 

RUN apt-get update --fix-missing; \
    apt-get install -y software-properties-common; \ 
    rm -rf /var/lib/apt/lists/* ; \ 
    add-apt-repository -y ppa:deadsnakes/ppa; \ 
    apt update -y; apt upgrade -y; \ 
    apt install -y python3.6; \ 
    apt install -y python3-pip; \ 
    yes | python3 -m pip install --upgrade pip; \ 
    yes | python3 -m pip install virtualenv pip; \ 
    apt-get install -y python3-venv; \ 
    yes | python3 -m venv my_py_venv; \ 
    add-apt-repository -y ppa:git-core/ppa; \ 
    apt update -y ; \ 
    apt install -y git; \ 
    yes | python3 -m pip install --upgrade pip; \ 
    yes | python3 -m pip install virtualenv; \ 
    source my_py_venv/bin/activate; \ 
    yes | pip3 install wheel; \
    yes | pip3 install selenium; \ 
    yes | pip3 install git+https://github.com/behave/behave; \ 
    yes | pip3 install allure-behave; rm -rf /var/lib/apt/lists/*;

I have downloaded the ChromeDriver (https://chromedriver.storage.googleapis.com/index.html?path=83.0.4103.14/) but I am not sure which version to use (chromedriver_win32.zip OR chromedriver_linux64.zip).

And while instantiating the Chrome Browser instance, should I use Windows Directory Syntax ('\') or Linux Directory Syntax ('/') in the code below:

driver = webdriver.Chrome('/steps/chromedriver')

Thank you for your time and suggestions.

  • Does this answer your question? [How can I run Selenium tests in a docker container with a visible browser?](https://stackoverflow.com/questions/62011537/how-can-i-run-selenium-tests-in-a-docker-container-with-a-visible-browser) – Sida Zhou Feb 23 '21 at 06:49

1 Answers1

0

there is plenty of examples how you can run your tests against external selenium grid (hub). There is also a docker support for them. Browser images as firefox,chrome,opera .. etc also can be found in selenium repo. https://github.com/SeleniumHQ/docker-selenium

Scrolling below you can find examples how to create setup by your needs. Also i will advice you to create container with the tests you made and modify them to accept env variables to change/run your tests.

Like this you can run everything isolated and on different locations/datacenters.

Infern0
  • 2,565
  • 1
  • 8
  • 21
  • do I need to use Selenium Grid to make external browser work with Docker? – ScarletMcLearn4 Apr 21 '20 at 19:57
  • selenium grid is the "orchestrator" of browsers. each of this is encapsulated in container. grid can be in one location, each browser node also in different location... or just in one. if you wish to test something you just add seleniumAddress (selenium hub) to your test framework, from there orchestrator balance the load over the nodes. – Infern0 Apr 22 '20 at 05:41