title: Python Behave 'Context' object has no attribute 'find_element'
body: <p>I have a sample BDD Python Behave code.  When i run behave test.feature the homepage opens but then I get the following error:</p>
  
  <pre><code>'Context' object has no attribute 'find_element'
  </code></pre>
  
  <p>Full error is:</p>
  
  <pre><code>Scenario Outline: visit test and search for product -- @1.1 By product  # test.feature:27
  Given we are on the test homepage                                     # steps\steps.py:37
  When we enter "&lt;product&gt;" in the search field                           # steps\steps.py:43
    Traceback (most recent call last):
      File "C:\Python27\lib\site-packageehave\model.py", line 1456, in run
        match.run(runner.context)
      File "C:\Python27\lib\site-packageehave\model.py", line 1903, in run
        self.func(context, *args, **kwargs)
      File "steps\steps.py", line 50, in step
        search_field = context.find_element(By.XPATH, 'id("twotabsearchtextbox")')
    unner.py", line 214, in __getattr__eehave
        raise AttributeError(msg)
    AttributeError: 'Context' object has no attribute 'find_element'
  </code></pre>
  
  <p>My code snippet is:</p>
  
  <p>test.feature:</p>
  
  <pre><code>Feature: testing test
  
  Scenario Outline: visit test and search for product
      Given we are on the test homepage
      When we enter "&lt;product&gt;" in the search field
      And we click the search button
      Then the list of products are displayed
  
      Examples: By product
          | Forumla One |
          | PS4         |
          | Headphones  |
  </code></pre>
  
  <p>steps.py</p>
  
  <pre><code>from behave   import given, when, then
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.common.by import By
  
  @given ('we are on the test homepage')
  def step(context):
      context.browser.visit()
  
  
  @when ('we enter "{product}" in the search field')
  def step(context, product):
     search_field = context.find_element(By.XPATH, 'id("twotabsearchtextbox")')
     search_field.send_keys(product)
  
  @when ('we click the search button')
  def step(context):
     pass
  
  @then ('the list of products are displayed')
  def step(context):
      pass
  </code></pre>
  
  <p>browser.py</p>
  
  <pre><code>from selenium import webdriver
  
  class Browser(object):
  
      base_url = 'http://www.test.com'
      driver = webdriver.Chrome("E:\Selenium Server\chromedriver.exe")
      driver.implicitly_wait(10)
  
      def close(self):
          """
          close the webdriver instance
          """
          self.driver.quit()
  
      def visit(self, location=''):
          """
          navigate webdriver to different pages
          """
          url = self.base_url + location
          self.driver.get(url)
  
      def find_by_id(self, selector):
          """
          find a page element in the DOM
          """
          return self.driver.find_element_by_id(selector)
  </code></pre>
  
  <p>environment.py</p>
  
  <pre><code>from browser import Browser
  from selenium import webdriver
  
  def before_all(context):
    context.browser = Browser()
  
  def after_all(context):
    context.browser.close()
  </code></pre>
  
  <p>It is not finding find_element, I would like to use this so I can find the elements on the web page.  What is the correct syntax to use fine_element in Behave?</p>
  
  <p>Thanks, Riaz</p>