Skip to content

Instantly share code, notes, and snippets.

@mcbhenwood
Created November 8, 2012 15:50
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcbhenwood/4039622 to your computer and use it in GitHub Desktop.
Save mcbhenwood/4039622 to your computer and use it in GitHub Desktop.
Simple Behave environment file to start Selenium webdriver
"""
Hooking up Selenium to Behave.
For details, see:
http://pyuseful.wordpress.com/2012/11/08/running-cucumber-style-tests-in-django-using-behave/
"""
import logging
from selenium import webdriver
def before_all(context):
selenium_logger = logging.getLogger(
'selenium.webdriver.remote.remote_connection')
selenium_logger.setLevel(logging.WARN)
context.driver = webdriver.Firefox()
context.driver.implicitly_wait(3)
def after_all(context):
context.driver.quit()
@tjmcewan
Copy link

Hey, thanks for the selenium logger stuff - the debug output is a pretty annoying.

BTW the post link is broken.

@bittner
Copy link

bittner commented Oct 23, 2014

Very nice! That was the missing piece when starting with Behave and Selenium.

Hint: context.driver could be renamed to context.browser to better match the sample code in the Behave documentation (e.g. Tutorial, API).

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