title: Python Selenium: How to reuse a class from another class
body: <p>I'm new to Python and selenium. I need to write a login module that I can reuse in my test cases. Here's my 2 files. I need help to call the login module so that the browser launches and user can login. Then the second module starts and test case begins (in the same browser). I have written 2 class in 2 separate files. My code is below:</p>
  
  <p>mylogin.py file</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.common.exceptions import TimeoutException
  from selenium.common.exceptions import NoSuchElementException
  import unittest
  class myLoginclass(unittest.TestCase):
      @classmethod   
      def test_TC_1_login_page(self):       
          self.driver = webdriver.Firefox()
          self.driver.get(http://www.gmail.com)
          self.driver.find_element_by_xpath(".//*[@id='name-group']/input").send_keys("HELLO")
          self.driver.find_element_by_xpath(".//*[@id='password-group']/input").send_keys("WORLD")
          self.driver.find_element_by_id("loginButton").click()
  
  if __name__ == '__main__':
      unittest.main(failfast=True, exit=False)
  </code></pre>
  
  <p>The myorder.py file:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.common.exceptions import TimeoutException
  from selenium.common.exceptions import NoSuchElementException
  import unittest
  from mylogin import myLoginclass
  class myorderclass(unittest.TestCase):
      @classmethod   
      def test_TC_2_orderProcess(self):       
          self.driver.find_element_by_xpath("".//*[@id='aoTkt']/div/div")).click()
          self.driver.find_element_by_xpath(".//*[@id='presales']/input").click()
          self.driver.find_element_by_link_text("DISPATCH").click()
          self.driver.find_element_by_id("submitButton").click()
  
  if __name__ == '__main__':
      unittest.main(failfast=True, exit=False)
  </code></pre>