Selenium webdriver for lettuce
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Lettuce steps for Web Testing with Selenium 2

lettuce_webdriver provides a set of steps for use with the Cucumber BDD Python port lettuce using the selenium 2.8 or higher Python package.

The included matchers and syntax is inspired heavily by cucumber_watir.


Setting Up lettuce_webdriver

In your lettuce file, add an include statement for lettuce to learn about the additional step definitions provided by lettuce_webdriver and a setup that creates the selenium browser desired:

from lettuce import before, world
from selenium import webdriver
import lettuce_webdriver.webdriver

def setup_browser():
    world.browser = webdriver.Firefox()


lettuce stories are written in the standard Cucumber style of gherkin. For example:

Scenario: Filling out the signup form
  Given I go to ""
   When I fill in "Name" with "Foo Bar"
    And I fill in "Email" with ""
    And I fill in "City" with "San Jose"
    And I fill in "State" with "CA"
    And I uncheck "Send me spam!"
    And I select "Male" from "Gender"
    And I press "Sign up"
   Then I should see "Thank you for signing up!"

Included Matchers

The following lettuce step matchers are included in this package and can be used with Given/When/Then/And as desired.

# urls
I visit ""
I go to ""

# links
I click "Next page"
I should see a link with the url ""
I should see a link to "Google" with the url ""
I should see a link that contains the text "Foobar" and the url ""

# general
I should see "Page Content"
I see "Page Content"
I should see "Page Content" within 4 seconds
I should not see "Foobar"
I should be at ""
I should see an element with id of ""
I should see an element with id of "" within 2 seconds
I should not see an element with id of ""
The element with id of "cs_PageModeContainer" contains "Read"
The element with id of "cs_BigDiv" does not contain "Write"

# browser
The browser's URL should be ""
The browser's URL should contain ""
The browser's URL should not contain ""

# forms
I should see a form that goes to ""
I press "Submit"

# checkboxes
I check "I have a car"
I uncheck "I have a bus"
The "I have a car" checkbox should be checked
The "I have a bus" checkbox should not be checked

# select
I select "Volvo" from "Car Choices"
I select the following from "Car Choices":
The "Volvo" option from "Car Choices" should be selected
The following options from "Car Choices" should be selected:

# radio buttons
I choose "Foobar"
The "Foobar" option should be chosen
The "Bar" option should not be chosen

# text entry fields (text, textarea, password)
I fill in "Username" with "Smith"


lettuce_webdriver is maintained by Nick Pilon (@npilon on github and Bug fixes and feature patches may be submitted using github pull requests, and bug reports or feature requests as github issues.

lettuce_webdriver is fully compatible and recommended for use with BrowserStack (, which provides hosted remote Selenium instaces for all major browsers.