All Projects → seanpianka → Docker Python Xvfb Selenium Chrome Firefox

seanpianka / Docker Python Xvfb Selenium Chrome Firefox

Licence: mit
Dockerfiles for Python 3.6/2.7 & Selenium in a headless Chrome or Firefox environment

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects
python2
120 projects

Projects that are alternatives of or similar to Docker Python Xvfb Selenium Chrome Firefox

Selenium Python Helium
Selenium-python but lighter: Helium is the best Python library for web automation.
Stars: ✭ 2,732 (+3231.71%)
Mutual labels:  selenium, chrome, firefox
Dockselpy
Dockerized Selenium and Python with support for Chrome, Firefox and PhantomJS
Stars: ✭ 237 (+189.02%)
Mutual labels:  selenium, chrome, firefox
Singlefile
Web Extension for Firefox/Chrome/MS Edge and CLI tool to save a faithful copy of an entire web page in a single HTML file
Stars: ✭ 4,417 (+5286.59%)
Mutual labels:  selenium, chrome, firefox
Chrome Export Passwords
Show all your chromium passwords in format ready to import in other browser like FireFox
Stars: ✭ 80 (-2.44%)
Mutual labels:  chrome, firefox
Gmail Fixed Font
Use your browser's monospace font for message body text in Gmail
Stars: ✭ 44 (-46.34%)
Mutual labels:  chrome, firefox
Advent Of Code Charts
Inject charts in your private leaderboard page for Advent of Code
Stars: ✭ 46 (-43.9%)
Mutual labels:  chrome, firefox
Browserpass Legacy
Legacy Browserpass repo, development is now happening at:
Stars: ✭ 1,020 (+1143.9%)
Mutual labels:  chrome, firefox
Ubo Youtube
Easier way to exempt your favorite YouTube channels from adblocking.
Stars: ✭ 57 (-30.49%)
Mutual labels:  chrome, firefox
Octopatcher
Arrgh Some Patchy Goodness to GitHub!
Stars: ✭ 49 (-40.24%)
Mutual labels:  chrome, firefox
Better Onetab
📑 A better OneTab for Chrome 📝 Temporarily removed from firefox ⚠️ without maintaining in a period & any cooperative purpose are welcome
Stars: ✭ 1,097 (+1237.8%)
Mutual labels:  chrome, firefox
Persian Twitter
A WebExtension which improves Twitter & TweetDeck user experience for Persian users
Stars: ✭ 66 (-19.51%)
Mutual labels:  chrome, firefox
Uget Chrome Wrapper
Moved to https://github.com/ugetdm/uget-integrator and https://github.com/ugetdm/uget-extension
Stars: ✭ 74 (-9.76%)
Mutual labels:  chrome, firefox
Adguardbrowserextension
AdGuard browser extension
Stars: ✭ 1,018 (+1141.46%)
Mutual labels:  chrome, firefox
Himawari 8 Chrome
🛰 Experience the latest image from the Himawari, GOES, Meteosat, and DSCOVR satellites
Stars: ✭ 48 (-41.46%)
Mutual labels:  chrome, firefox
Cookie Autodelete
Firefox and Chrome WebExtension that deletes cookies and other browsing site data as soon as the tab closes, domain changes, browser restarts, or a combination of those events.
Stars: ✭ 1,015 (+1137.8%)
Mutual labels:  chrome, firefox
Mue
Fast, open and free-to-use new tab page for modern browsers
Stars: ✭ 56 (-31.71%)
Mutual labels:  chrome, firefox
Disable Webassembly
Browser hacks to disable WebAssembly (WASM)
Stars: ✭ 63 (-23.17%)
Mutual labels:  chrome, firefox
Spam Bot 3000
Social media research and promotion, semi-autonomous CLI bot
Stars: ✭ 79 (-3.66%)
Mutual labels:  selenium, firefox
Screensharing Extensions
Sample code for developing an OpenTok screen-sharing extension for Google Chrome and Firefox
Stars: ✭ 71 (-13.41%)
Mutual labels:  chrome, firefox
Duplicate Tab
Press Alt+Shift+D to duplicate the current tab (Option+Shift+D on Mac).
Stars: ✭ 40 (-51.22%)
Mutual labels:  chrome, firefox

docker-python-xvfb-chromium-selenium

Dockerfiles for images running Python 2.7 or Python 3.6 + Selenium with either Chrome or Firefox and using Xvfb for the X display (necessary for running Selenium headlessly).

Dependencies

  • Python 2.7 or Python 3.6
  • Google Chrome/Chromium or Firefox (Unstable, from Debian)
  • Chromedriver or Geckodriver
  • Selenium
  • Xvfb

Usage Tutorial

Your Project Files

A project directory under /opt/app/ is created within the Docker image. This is where all of your project files will be copied over (/opt/app/ is a common convention). Create a new file (this will be our project file for this tutorial) using $ touch test.py. We'll write our application in this file, see below:

from selenium import webdriver

# use selenium, instantiate Chrome browser instance
options = webdriver.chrome.options.Options()
options.add_argument("--no-sandbox")
options.add_argument("--disable-setuid-sandbox")
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(chrome_options=options)

# perform a test request to verify that selenium and chrome are working properly
driver.get("https://httpstat.us/200")
if "200 OK" in driver.page_source:
    print('Selenium successfully opened with Chrome (under the Xvfb display) and navigated to "https://httpstat.us/200", you\'re all set!')
Your Project's Entry Point

Then, modify the invocation shell script run.sh (AVAILABLE HERE) and ensure the last line contains the correct Python invocation of the entry point into your application. This script is what the Dockerfile will use, along with Bash, to invoke the Python interpreter on the entry point you specify.

python3 test.py  # change this line to invoke the entry point of your application!
Dockerfile Explanation and Build Steps

Now, we're going to build and run our project! Yay! Start by modifying the Dockerfile (AVAILABLE HERE) for Python 3 + Chrome.

First, the Dockerfile installs chromium, Xvfb, and Python. Then, a project directory is created, the Python project dependencies (and Selenium) are installed, and your project code is copied into the image. Lastly, env DISPLAY is set to an open display port for Xvfb to use (as we require an X Windows server), your invocation script run.sh (AVAILABLE HERE) is copied into the image and invoked with /bin/bash.

Now, build the image and spawn a new container using that image:

$ docker build -t docker-python-xvfb-selenium-chrome-firefox .
Executing Your Project

Now, create a new container from your image:

$ docker run --rm docker-python-xvfb-selenium-chrome-firefox

You should see the following text output to the terminal:

Selenium successfully opened with Chrome (under the Xvfb display) and navigated to "https://httpstat.us/200", you're all set!

Done!

Pre-written Dockerfiles for any combination of Python 2/Python 3 and Chrome/Firefox are available!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].