Testing Setup gives 500, but dev server works okay

14 views
Skip to first unread message

Timothy W. Cook

unread,
May 25, 2015, 11:29:52 AM5/25/15
to django...@googlegroups.com
I have a project that I started, then decided I should apply a TDD approach. 

Well the user registration and login portion already works but I am attempting to add some tests to it.
The user can register, is redirected back to the main page with a Login button.  

Here is the test code:

    def test_visitor_can_register_and_login_logout(self):
        self.browser.get(self.server_url)
        self.browser.find_element_by_id('id_register').click()
        self.browser.find_element_by_id('id_username').send_keys(TEST_USER)
        self.browser.find_element_by_id('id_email').send_keys(TEST_EMAIL)
        self.browser.find_element_by_id('id_password1').send_keys(TEST_PASSWORD)
        self.browser.find_element_by_id('id_password2').send_keys(TEST_PASSWORD)
        self.browser.find_element_by_id('submit_registration').click()
        time.sleep(10)
        ## Existing user is invited to login
        self.browser.find_element_by_id('id_login').click()
        self.browser.find_element_by_id('id_login').send_keys(TEST_USER)
        self.browser.find_element_by_id('id_password').send_keys(TEST_PASSWORD)
        self.browser.find_element_by_id('log_me_in').click()

        ## test user is logged in and can logout
        self.browser.find_element_by_id('id_logout').click()
        self.browser.find_element_by_tag_name('button').click()
        ##redirected back to main page
        self.browser.find_element_by_id('id_login')

I see the main page load, the registration page loads and the inputs are filled in. 
When the submit_registion button is clicked I get a 500.  You can see I put a sleep in there just so I could see it and verify that the process isn't running too fast for the server to respond. 

I originally had the registration and login in separate tests but I understand that this might require TransactionTestCase ?  I am using 
from django.test import LiveServerTestCase in this class.

I have one other test before that runs fine.

Any ideas?  Tips on troubleshooting this functional test? 





============================================
Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

Timothy W. Cook

unread,
May 25, 2015, 11:32:13 AM5/25/15
to django...@googlegroups.com
I should add that the actual error is:

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"id_login"}

because the main page never loads so it can't find the login button, 

--
Reply all
Reply to author
Forward
0 new messages