How to Install Selenium as a Unix daemon? How to Install Selenium as a Unix daemon? selenium selenium

How to Install Selenium as a Unix daemon?


I've tried to make selenium-server-standalone running as a service, but it failed to launch browser (I've tried chrome and firefox).So it is better to do as Mahsum Akbas says.

Here is an example of how you could make it as a service:bash - Start Java jar by service (linux)...

But it will not launch real browsers. I was using jenkins service to launch real browser, but it failed too. I had success in launching tests using headless browser. But there was the problem with some tests were failing.

And also, you could try this

EDITED: I've achieved it in such way using systemd:

sudo vim /etc/systemd/system/selenium-server-hub.service[Unit]Description=Selenium Server Standalone hubStartLimitIntervalSec=5After=syslog.target[Service]Type=simpleRestart=alwaysRestartSec=8User=spacerExecStart=/bin/bash -c "export DISPLAY=:10 && /usr/bin/java -jar /home/spacer/seleniumserver/selenium-server.jar -role hub"SuccessExitStatus=143[Install]WantedBy=multi-user.targetsudo vim /etc/systemd/system/selenium-server-hub.service[Unit]Description=Selenium Server nodeStartLimitIntervalSec=0After=selenium-server-hub.target[Service]Type=simpleRestart=alwaysRestartSec=8User=spacerExecStart=/bin/bash -c "export DISPLAY=:10 && /usr/bin/java -Dwebdriver.chrome.driver=/bin/chromedriver -jar /home/spacer/seleniumserver/selenium-server.jar -role node -hub 'http://192.168.0.101:4444/grid/register/'"SuccessExitStatus=143[Install]WantedBy=multi-user.target

I connect to my linux server through RDP and it opens display :10. Your display could be different.You could check your displays by command:

ps e | grep -Po " DISPLAY=[\.0-9A-Za-z:]* " | sort -u

PS: Chrome and Firefox are starting, even though chromedriver could not be started when I was launching selenium-server hub and node from terminal as usual.


you can use nohup command. so, you can redirect output to nohup file and there will not be kill session after disconnect ssh.

nohup java -jar selenium-server-standalone-2.48.2.jar -role hub &nohup java -jar selenium-server-standalone-2.48.2.jar -role node  -hub http://localhost:4444/grid/register &