title: Only able to login ONCE with Selenium and Django Testing
body: <p>I'm testing using Django's tests and Selenium so I can run tests with a live browser. But it won't let me log in more then once.</p>
  
  <p>I am using Django's <code>StaticLiveServerTestCase</code> to access both static and media files live. I login by going to the page. I've tried putting the login code both in <code>setUpClass</code> to run once at the beginning and <code>setUp</code> to run each time. Both only let me log in once.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>from django.contrib.staticfiles.testing import StaticLiveServerTestCase
  from django.contrib.auth.models import User
  from selenium import webdriver
  
  @override_settings(DEBUG=True) 
  class LoginTest(StaticLiveServerTestCase):
    @classmethod
    def setUpClass(cls):
      super().setUpClass()
  
      # create user
      cls.user = User.objects.create_user( 'Testing User', 'somewhere@wherever.com', 'pwd')
  
      # initalize webdriver
      cls.driver = webdriver.Chrome() # doesn't work on FireFox either
      cls.driver.set_window_size(1280,800)
      cls.driver.implicitly_wait(5)
  
      # login - send username and password to login page
      cls.driver.get(cls.live_server_url+'/accounts/login/')
      cls.driver.implicitly_wait(10)
      username = cls.driver.find_element_by_name('login')
      username.clear()
      username.send_keys(cls.user.username)
      password = cls.driver.find_element_by_name('password')
      password.clear()
      password.send_keys("pwd")
      password.submit() # eubmits form
  
    @classmethod
    def tearDownClass(cls):
      cls.driver.quit() # quit after tests have run
      super().tearDownClass()
  
    def test_login_one(self): # this test PASSES
      self.driver.get(self.live_server_url) # go to home page
      login_menu = self.driver.find_element_by_id('login_menu')
      self.assertTrue(
          # if logged in username is in text of #login_menu
          self.user.username in login_menu.text
      )
  
    def test_login_two(self): # this test FAILS
      self.driver.get(self.live_server_url) # go to home page
      login_menu = self.driver.find_element_by_id('login_menu')
      self.assertTrue(
          # if logged in username is in text of #login_menu
          self.user.username in login_menu.text
      )
  </code></pre>
  
  <p>This code logs in once at the beginning. But I've also tried code that logs in each time a test is run (using <code>setUp</code> instead of 'setUpClass') and it still only lets me log in once.</p>
  
  <p>Any idea what's going on?</p>
  
  <p><strong>Update:</strong>
  I tried logging in a second time on <code>test_log_in_two</code> (the 2nd test) and I saw a "username and password not found" error in the chrome window.</p>