Skip to content

Instantly share code, notes, and snippets.

Last active Dec 18, 2015
What would you like to do?
Dependencies for dead simple acceptance testing using pytest and selenium
curl -O
echo -e "Installing pip..."
sudo python
echo -e "Done."
echo -e "Installing Python packages..."
sudo pip install pytest
sudo pip install selenium
sudo pip install ipython
sudo pip install tornado
sudo pip install pyzmq
echo -e "Done."
if [ -z $(which brew) ]
echo -e "Installing Homebrew..."
ruby -e "$(curl -fsSL"
echo -e "Done."
echo -e "Installing Homebrew packages..."
brew install phantomjs
brew install chromedriver
echo -e "Done."
import pytest
from selenium import webdriver
BROWSER = {'chrome': webdriver.Chrome,
'firefox': webdriver.Firefox,
'headless': lambda: webdriver.PhantomJS(service_args=["--ignore-ssl-errors=yes"])
def pytest_addoption(parser):
parser.addoption('--url', action='store')
parser.addoption('--browser', action='store', default='headless')
parser.addoption('--username', action='store')
parser.addoption('--password', action='store')
def url(request):
return request.config.getoption('url')
def username(request):
return request.config.getoption('username')
def password(request):
return request.config.getoption('password')
def browser(request):
browser = request.config.getoption('browser')
driver = BROWSER[browser]()
request.addfinalizer(lambda: driver.quit())
return driver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment