Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
selenium-rum
"""
Instructions
************
1. install ubuntu deps:
-----------------------
sudo apt-get python-pip
sudo apt-get install firefox
sudo apt-get install chromium-browser
sudo apt-get intall xvfb
2. install python deps:
-----------------------
sudo pip install selenium
sudo pip install xvfbwrapper
3. install chromedriver:
------------------------
wget -N http://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv -f chromedriver /usr/local/bin/chromedriver
4. adjust URL in script below.
5. run the script!
"""
import time
from selenium import webdriver
from xvfbwrapper import Xvfb
URL = 'http://foo'
INTERVAL = 15
print 'starting xvfb for virtual display...\n'
with Xvfb() as xvfb:
while True:
for browser in ('Firefox', 'Chrome'):
browser_class = getattr(webdriver, browser)
print 'starting browser: %s' % browser
driver = browser_class()
driver.set_page_load_timeout(10)
print 'navigating to: %s' % URL
try:
driver.get(URL)
except Exception as e:
print e
print 'closing browser\n'
driver.quit()
time.sleep(INTERVAL)
@danriti

This comment has been minimized.

Copy link

danriti commented Dec 1, 2015

Had to install chromium-browser instead of chrome.

@cgoldberg

This comment has been minimized.

Copy link
Owner Author

cgoldberg commented Dec 1, 2015

updated instructions to say chromium-driver.

@cgoldberg

This comment has been minimized.

Copy link
Owner Author

cgoldberg commented Dec 1, 2015

added 10 sec pageload timeouts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.