by Kevin Schroeder | 6:08 am

… is very easy to do.

You need two things.  1) Xvfb for the virtual screen, 2) systemd.  (And the Selenium Server binary, of course)

First Xvfb

1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=X Virtual Frame Buffer Service
After=network.target
 
[Service]
Type=simple
User=magiumlib
ExecStart=/usr/bin/Xvfb :99 -screen 0 1024x768x24
 
[Install]
WantedBy=selenium.target

This will start up the virtual framebuffer so Selenium has a virtual screen to run the browser on.  Next up is the Selenium service itself.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Unit]
Description=Selenium
After=xvfb.target</p>
[Service]
Type=simple
User=magiumlib
PIDFile=/var/spool/selenium/pid/master.pid
EnvironmentFile=-/etc/sysconfig/network
Environment=DISPLAY=:99
Environment=DBUS_SESSION_BUS_ADDRESS=/dev/null
ExecStart=/bin/java -Dwebdriver.chrome.driver=/var/www/magiumlib/bin/chromedriver -Dwebdriver.chrome.logfile=/home/magiumlib/chrome.log -Dselenium.LOGGER=/home/magiumlib/selenium.log -jar /var/www/magiumlib/bin/selenium-server-standalone-2.53.0.jar
ExecStop=kill `cat /var/spool/selenium/pid/master.pid`
 
[Install]
WantedBy=multi-user.target

Voila!  Automated Selenium.

Comments

No comments yet...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.