Skip to content
A starter project structure for creating selenium tests with python
Branch: master
Clone or download
Latest commit 670e3ed May 7, 2015


Starter set up for writing selenium tests with Python. The Goal is to make it easier to write and run tests using Selenium for multiple browsers and devices. With this repo, you should be able to just start writing your tests and not be concerned with the basic set up of your test framework. This has options to also run on browserstack but could easily be modified to use another service with some elementary coding.

Installing Selenium

  • Install pip first if needed obviously (google is your friend here)
  • pip install -U selenium

Getting Started

  • You can add more tests by adding modules to the tests directory. Copy the structure in the examples and your tests should be executed automagically by the above.
  • You will likely want to update the data in the file. But should not need to update anything in the file unless you are applying a general fix to this repo that you plan to contribute..

General Examples

To run all tests on Firefox


To override the base url you set in

python --base_url ""

To only run one test

python --test ""

To see more options

python --help

Browserstack options

  • Before anything, you need to get your Selenium automate username and automate value from the following URL.
  • Once you have those values modify your ~/.bash_profile to end with the following. (use ~/.bashrc instead if on linux)
  • Then run the following in your terminal (remember to modify to ~/.bashrc if on linux)
source ~/.bash_profile

Open a tab and run the following to start the local testing server. That will make sure you can still access the site via the correct IP address, etc.

./local_testing_binaries/osx/BrowserStackLocal $SELENIUM_AUTOMATE_VALUE localhost,3000,0 -forcelocal -vv

Then Run the following to execute the tests and hook into the browser stack local testing server

python --browserstack --use_local

Browserstack Examples

To run with only in the desktop browsers:

python --browserstack --mobile

To run with only the in the desktop browsers:

python --browserstack --desktop

To override the base url you set in

python --browserstack --capabilities "{'os_version': '7', 'browser_version': '8.0', 'os': 'Windows', 'resolution': '1024x768', 'browser': 'IE'}"

Browserstack Notes

  • For more browserstack options, you can see more details here
  • You will notice that your username and value are hard coded in those examples though. Just replace those areas with the environment variables we set up to make your code more shareable.
  • Local testing is VERY slow... Do as you wish
You can’t perform that action at this time.