I am creating Selenium tests for my App. I can create a new user, but I can't seem to figure out how to have it deleted from the database.
After the tests run successfully the first time, subsequent tests fail because the username already exists. **Why am I not able to query the newly created record in the debugger despite being able to see the new record on the page?** **How do I delete a record from the database in a test?** This is what I have been doing: from selenium import webdriver from django.utils import unittest from forum.models import Question, Answer, User class TestOSQAAuthentication(unittest.TestCase): scheme = 'http' host = 'localhost' port = '4444' def setUp(self): self._driver = webdriver.Firefox() self._driver.implicitly_wait(25) def test_anon_can_create_new_account_manually(self): self._driver.get('http://localhost:8000/account/local/register/') self._driver.find_element_by_id('id_username').send_keys('MrManual') self._driver.find_element_by_id('id_email').send_keys('t...@gmail.com') self._driver.find_element_by_id('id_password1').send_keys('test') self._driver.find_element_by_id('id_password2').send_keys('test') self._driver.find_element_by_id('bnewaccount').click() # verify MrManual was created self._driver.get('http://localhost:8000/users/') self._driver.find_element_by_link_text('MrManual') # MrManual seems to be created, but I don't see MrManual in the database during debugging with: # import ipdb; ipdb.set_trace() #ipdb> User.objects.all() #[<User: Bryan>, <User: Kallie>, <User: Stalin>] # here I am trying to delete the user from the database directly. User.objects.filter(username="MrManual").delete() """For some reason I can't delete the record from the database from the test. Selenium can find the new user in the browser, but I can't query the database to find it.""" -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/tZ8Wiygvk_MJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.