A suite of steps for planterbox for web testing with Selenium
- Install
planterboxandplanterbox-webdriver:pip install planterbox planterbox-webdriver - Add a
unittest.cfgto your project that enablesplanterbox:
[unittest] plugins = planterbox [planterbox] always-on = True
3. Create a package containing your tests; its __init__.py defines the steps you will have available in your .feature files.
This package must be detected by nose2 as containing tests; see nose2's docs for details.
- Add a "before" hook that sets up a webdriver for your tests:
@hook('before', 'feature')
def create_webdriver(test):
from selenium import webdriver
test.browser = webdriver.Firefox()
from planterbox_webdriver.webdriver import *if you want steps that let you find elements in your tests with XPathfrom planterbox_webdriver.css_selector_steps import *for steps that let you find elements in your tests with jQuery-style CSS selectors- Add a
.featurefile in this package containing tests specified using Gherkin.planterboxwill turn these into appropriate test case objects and give them to nose to run. - Run your tests:
nose2