Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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