Created
November 8, 2012 15:50
-
-
Save mcbhenwood/4039622 to your computer and use it in GitHub Desktop.
Simple Behave environment file to start Selenium webdriver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very nice! That was the missing piece when starting with Behave and Selenium.
Hint:
context.driver
could be renamed tocontext.browser
to better match the sample code in the Behave documentation (e.g. Tutorial, API).