title: How do i use driver object in another test case in selenium python?
body: <p>How do i use driver object in another test case in selenium python?</p>
  
  <p><strong>file1.py</strong></p>
  
  <pre><code>import unittest
  import selenium
  from selenium import webdriver
  from selenium.webdriver.support.ui import Select
  from selenium.webdriver import ActionChains
  import time
  from selenium.webdriver import ChromeOptions, Chrome
  
  class LoginTest(unittest.TestCase):
      def test_login(self):
  
      opts = ChromeOptions()
      opts.add_experimental_option("detach", True)
  
      driver = webdriver.Chrome(executable_path="E:\Selenium\chromedriver.exe", options=opts)
      driver.maximize_window()
      driver.get("ABC.com")
  
      driver.switch_to.alert.accept()
  
  
      driver.find_element_by_id("UserName").send_keys("aaa")
      driver.find_element_by_id("txtPassword").send_keys("aaa")
      driver.find_element_by_id("btnLogin").submit()
  
      # time.sleep(5)
      driver.implicitly_wait(10)
  
      driver.switch_to.active_element
      # driver.switch_to.alert.accept()
      time.sleep(5)
      select = Select(driver.find_element_by_id('aaa'))  
      select.select_by_index(12) 
      time.sleep(5)
      select = Select(driver.find_element_by_id('aaa'))  
      select.select_by_index(0) 
      time.sleep(5)
      driver.find_element_by_id("aaa").click()
  
      time.sleep(10)
  
  if __name__ =="__main__":
      unittest.main()
  </code></pre>
  
  <p><strong>file2.py</strong></p>
  
  <pre><code>import unittest
  from selenium.webdriver import ActionChains
  from selenium import webdriver
  
  
  class SearchList(unittest.TestCase):
  def test_Search(self):
  
      ABC= driver.find_element_by_xpath("//*[@id='topmenuhide'']/ul/li[6]/a")
      SearchAndList =driver.find_element_by_xpath("//*[@id='topmenuhide']/ul/li[6]/ul/li[2]/a")
  
      actions = ActionChains(driver)
      actions.move_to_element(ABC).move_to_element(SearchAndList).click().perform()
  
  
  if __name__ =="__main__":
    unittest.main()
  </code></pre>
  
  <p>But in file 2 system is giving error </p>
  
  <blockquote>
    <p>NameError: name 'driver' is not defined</p>
  </blockquote>
  
  <ul>
  <li>How I can define driver here in file 2? </li>
  <li>Without opening the duplicate browser?
  please help in this regard</li>
  </ul>