Skip to content

Instantly share code, notes, and snippets.

@sgerrand
Forked from 3kwa/bootstrap.sh
Last active December 18, 2015 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgerrand/5771782 to your computer and use it in GitHub Desktop.
Save sgerrand/5771782 to your computer and use it in GitHub Desktop.
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
echo -e "Installing pip..."
sudo python get-pip.py
rm get-pip.py
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) ]
then
echo -e "Installing Homebrew..."
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
echo -e "Done."
fi
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')
@pytest.fixture(scope="session")
def url(request):
return request.config.getoption('url')
@pytest.fixture(scope="session")
def username(request):
return request.config.getoption('username')
@pytest.fixture(scope="session")
def password(request):
return request.config.getoption('password')
@pytest.fixture(scope="session")
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