Skip to content

Instantly share code, notes, and snippets.

@jaredhirsch
Created July 22, 2012 05:26
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 jaredhirsch/3158544 to your computer and use it in GitHub Desktop.
Save jaredhirsch/3158544 to your computer and use it in GitHub Desktop.
how to run selenium tests inside the automation-tests directory in the 123done or myfavoritebeers.org repos

how to run selenium tests inside the automation-tests directory in the 123done or myfavoritebeers.org repos

Node bindings don't exist for Selenium 2 API (webdriver), so we're using python bindings instead. This requires some python-centric setup, but it shouldn't take more than 15 minutes or so to get up and running.

check system-wide python requirements

You should have python 2.7 on your system (check python --version).

We have to install a bunch of python libraries. pip fetches packages; virtualenv sandboxes them. If pip and virtualenv aren't on your system already, you'll need to do this once (once per computer, not once per repo):

# only do this if pip and virtualenv aren't on your computer already
easy_install pip
pip install virtualenv (might need to use sudo)

build a sandboxed test environment

At the top-level of your repo, create a sandboxed python environment to install python dependencies (only need to do this once per clone):

# only do this once per clone
virtualenv test_env

Be sure you do not accidentally add the virtualenv directory (here, test_env) to git.

You can activate the sandbox, meaning link installed programs, via:

. test_env/bin/activate

And when you want to stop using the sandbox, you can exit via deactivate. Deactivating the virtualenv doesn't destroy it.

So, activate the virtualenv, and install the python requirements in requirements.txt:

pip install -Ur automation-tests/requirements.txt

Sweet. You're almost ready to go.

create a test user in credentials.yaml

Before you can run tests on dev or stage or prod, you need to create a dummy persona account, and then put the test account info into automation-tests/credentials.yaml.

actually run the tests

Yay wut! You're good to go. Here's an example incantation. If you run this from top-level in the repo, and you're on a mac that has firefox, you'll see the browser pop open and run all the tests:

py.test --pdb --destructive --driver=firefox \
    --baseurl=http://dev.123done.org --browsername=firefox --platform=mac \
    --credentials=automation-tests/credentials.yaml -q automation-tests

writing automation tests

The most important thing to note is that the code under automation-tests/browserid is a git subtree pulled from github.com/6a68/bidpom.git. Changes made within that directory should be merged to the upstream repo; see git-subtree help file for details.

@jaredhirsch
Copy link
Author

Note that the baseurl in the example snippet is specific to the 123done repo; you should change it if you're running automated tests for myfavoritebeers.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment