I decided to record the process of starting Selenium server as it was not easy to find such info on the fly.
I follow instructions of Dan Straw literally:
sudo su mkdir /usr/lib/selenium/ cd /usr/lib/selenium/ wget http://selenium.googlecode.com/files/selenium-server-standalone-2.0a5.jar mkdir -p /var/log/selenium/ chmod a+w /var/log/selenium/
Take this attachment, and save it as /etc/init.d/selenium
This script lets you to start, stop, restart etc. the server in a conventional to Linux environment way, by passing ‘start’, ‘stop’ arguments. Selenium server will be listening on port 4443, while default port is 4444; keep in mind when playing with examples on the web.
Add the script so that it starts automatically when the server does (don’t yet understand how this works):
update-rc.d selenium defaults
Now, to start selenium server:
To check if server is running:
sudo lsof -i :4443
Without “sudo”, it is possible that system will show that no process is listening on the port, while selenium may be running normally. This can happen if you started selenium using “sudo”.
Below is a snippet of Python code that starts server, initializes selenium client (browser), connects to the server, and stops the client:
import time, os from selenium import selenium def main(): os.system("/etc/init.d/selenium start") # wait for server to start; otherwise can get "connection refused" error time.sleep(5) sel = selenium("localhost", 4443, "*firefox", "http://localhost:8000/") sel.start() os.system("/etc/init.d/selenium stop") pass if __name__ == "__main__": main()