Skip to content

Instantly share code, notes, and snippets.

@nitinthewiz
Forked from aurelijusb/Dockerfile
Created January 23, 2020 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitinthewiz/2e2975253ea9ad9f96c208c6d8f4aa3e to your computer and use it in GitHub Desktop.
Save nitinthewiz/2e2975253ea9ad9f96c208c6d8f4aa3e to your computer and use it in GitHub Desktop.
Code snippets for Minsk PHP Night presentation: Headless browsers and friends
docker-compose up -d

Connect via Remote desktop (E.g. Vinagre) to 127.0.0.0:5900

See UI automation in action

version: '2'
services:
uitesting:
container_name: virtual-desktops
image: virtual-desktops
volumes:
- ./example-test.sh:/custom/example-test.sh:ro
ports:
- 127.0.0.1:5900:5900
# entrypoint: "/bin/bash -c 'Xvfb :1 -screen 0 1024x768x16 & x11vnc -display :1 & DISPLAY=:1.0 firefox http://aurelijus.banelis.lt/en'"
entrypoint: /custom/example-test.sh
FROM ubuntu:latest
RUN apt-get update && \
apt-get install -y xvfb firefox python-pip xdotool x11vnc
RUN apt-get install -y wget
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.16.1/geckodriver-v0.16.1-linux64.tar.gz
RUN tar zxvf geckodriver-v0.16.1-linux64.tar.gz && mv geckodriver /usr/bin/geckodriver
ENV DISPLAY=:1.0
EXPOSE 5900
# Xvfb :1 -screen 0 1024x768x16 &
# x11vnc -display :1
# DISPLAY=:1.0
ENTRYPOINT ["bash"]
#!/usr/bin/env bash
Xvfb :1 -screen 0 1024x768x16 &
x11vnc -display :1 &
DISPLAY=:1.0 firefox http://aurelijus.banelis.lt/en &
BROWSER_PID=$!
sleep 10
xdotool mousemove 240 20 click 1
sleep 1
xdotool mousemove 50 20 click 1
sleep 1
xdotool mousemove 300 50 click 1
sleep 1
xdotool key --repeat=50 BackSpace
sleep 1
xdotool key e v e n t s p a c e period b y
sleep 1
xdotool key Return
wait $BROWSER_PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment