title: Selenium Webdriver Python AttributeError type object has no attribute
body: <p>I am getting the following error in my Python Selenium Webdriver script.</p>
  
  <pre><code>Error
  Traceback (most recent call last):
    File "C:\Webdriver\ClearCore 501\TestCases\VariablesPage_TestCase.py", line 87, in test_add_variables
      variablesPage = projectnavigator.select_projectNavigator_item("Variables") # Select the Variables link from the left hand Project Navigator, it returns the Variables page object
    File "C:\Webdriver\ClearCore 501\Menus\project_navigator.py", line 24, in select_projectNavigator_item
      variables_projectnavigator_link = self.driver.find_element(*MainPageLocators.variables_project_navigator_link2).click()
  AttributeError: type object 'MainPageLocators' has no attribute 'variables_project_navigator_link2'
  </code></pre>
  
  <p>I think it is because the class has not been instantiated.  You cannot access a member variable without an instance of the class.
  I think I have instantiated my class like this:</p>
  
  <pre><code>projectnavigator = project_navigator.ProjectNavigatorPage(self.driver)
  </code></pre>
  
  <p>I do not know why I am getting the error.</p>
  
  <p>My code snippet is as follows:</p>
  
  <p>class ProjectNavigatorPage</p>
  
  <pre><code>    # This class defines the methods for the the ClearCore left hand project navigator
  # i.e. Selecting the Data Objects, Datasets, Variables, Feeds, Mappings, Data Previews etc
  
  import time
  from Pages.base import BasePage
  #from Pages.login import LoginPage
  from Pages.admin import AdministrationPage
  from Locators.locators import MainPageLocators
  from Pages.variables import VariablesPage
  
  class ProjectNavigatorPage(BasePage):
  
      # Select an item from the Project Navigator  e.g. Data Objects tab, Datasets, Variables etc
      def select_projectNavigator_item(self, menu_item):
          if menu_item == "Data Objects":
              #LoginPage.clickAdministration()
              #self.clickAdministration(self)
              pass
          elif menu_item == "Datasets":
              pass
          elif menu_item == "Variables":
              variables_projectnavigator_link = self.driver.find_element(*MainPageLocators.variables_project_navigator_link2).click()
              return VariablesPage(self.driver)
  
          elif menu_item == "Feeds":
              pass
          elif menu_item == "Mappings":
              pass
          elif menu_item == "Data Previews":
              pass
  </code></pre>
  
  <p>class VariablesPage_TestCase</p>
  
  <pre><code>    # This class defines the tests for the the Variables page.  e.g. Add a variable, Name, Address, DOB
  
  import unittest
  import time
  import datetime
  from selenium import webdriver
  from Locators import locators, Globals
  from Locators import element
  from Menus import project_navigator
  from Pages import login
  from Pages import admin
  from Pages import main_dashboard
  from Pages import data_objects, variables
  from Menus import toolbar
  from Pages import datamaps
  from Pages import datasets
  from Pages import base
  from Utilities import Utilities
  from Pages import data_previews
  from Pages import data_objects_saved_page
  import datetime
  from selenium.webdriver.support.ui import Select
  
  class VariablesPage_TestCase(unittest.TestCase):
  
      def setUp(self):
          #webdriver.DesiredCapabilities.FIREFOX["unexpectedAlertBehaviour"] = "accept"
          webdriver.DesiredCapabilities.INTERNETEXPLORER["unexpectedAlertBehaviour"] = "accept"
          #self.driver = webdriver.Firefox()
          #self.driver = webdriver.Ie("C:\QA\Automation\Python_projects\Selenium Webdriver\IEDriverServer_Win32_2.45.0\IEDriverServer.exe")
          self.driver = webdriver.Ie(Globals.IEdriver_path)
          self.driver.get(Globals.URL_justin_pc)
          self.login_page = login.LoginPage(self.driver)
          self.driver.implicitly_wait(100)
  
  
      def test_add_variables(self):
          print "*** Test add Variables ***"
          data_dashboard_page = self.login_page.userLogin_valid(Globals.login_username, Globals.login_password)
          md = main_dashboard.MainDashboardPage(self.driver)
          #main_dashboard.MainDashboardPage.select_project_from_drop_down(self)
          md.select_project_from_drop_down()
          data_configuration_page = data_dashboard_page.click_data_configuration2() # Click Data Configuration from the Project Navigator
          #assert data_dashboard_page.is_Data_Configuration_pageDisplayed(), "Data Configuration Page not displayed"
          print "data_configuration_page.is_Data_Configuration_pageDisplayed()"
          #print data_dashboard_page.is_Data_Configuration_pageDisplayed()
          time.sleep(10)
          assert data_configuration_page.is_Data_Configuration_pageDisplayed(), "Data Configuration Page not displayed"
          if data_configuration_page.is_Data_Configuration_pageDisplayed() == True:
              pass
          else:
             print "ERROR - Data Configuration page is not displayed"
         # tool_bar = toolbar.ToolbarPage(self.driver)
          projectnavigator = project_navigator.ProjectNavigatorPage(self.driver)
          variablesPage = projectnavigator.select_projectNavigator_item("Variables") # Select the Variables link from the left hand Project Navigator, it returns the Variables page object
  </code></pre>
  
  <p>class Locators</p>
  
  <pre><code>    from selenium.webdriver.common.by import By
  
  class MainPageLocators(object):
      usernameTxtBox = (By.ID, 'unid')
      passwordTxtBox = (By.ID, 'pwid')
      submitButton = (By.ID, 'button')
  
      # Data Configuration page
      DataConfiguration_button_xpath = (By.XPATH, '//div[. = "Data Configuration"]')
      data_config_elementTxt = (By.XPATH, '//span[contains(@title, "Data Configuration")][text()="Data Configuration"]')
      data_config_elementTxt2 = (By.XPATH, '//span[@title="Data Configuration"]')
  
      # Variables page
      variables_title_page_text = (By.XPATH, 'html/body/div[2]/div[2]/div/div[4]/div/div[2]/div/div[3]/div/div[5]/div/div[3]/div/div[4]/div/div[2]/div/div[2]/div/div/span') # This is the text beside the Add button (Variables)
      variables_project_navigator_link = (By.XPATH, '//span[@title="variables" and contains(text(), "variables")]')
      variables_projet_navigator_link2 = (By.XPATH, 'html/body/div[2]/div[2]/div/div[4]/div/div[2]/div/div[3]/div/div[5]/div/div[3]/div/div[2]/div/div/div/div/div/div/div[1]/div/div[2]/div/div[1]/div[3]/div[1]/div/div[2]/div/div[2]/span')
      variables_page_no_data_to_display_text = (By.XPATH, '//div[@class="gwt-Label absoluteLeft padding" and contains(text(), "No data to display")]') # This is the text where it says No data to display when you land on the variables page
  </code></pre>