'The "Add another XXX" link correctly adds items to the inline form.'

def test_add_inlines(self):

    self.admin_login(username='super', password='secret')
    self.selenium.get((self.live_server_url + reverse('admin:admin_inlines_profilecollection_add')))
    self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set')), 1)
    self.assertEqual(self.selenium.find_elements_by_css_selector('.dynamic-profile_set')[0].get_attribute('id'), 'profile_set-0')
    self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set#profile_set-0    input[name=profile_set-0-first_name]')), 1)
    self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set#profile_set-0    input[name=profile_set-0-last_name]')), 1)
    self.selenium.find_element_by_link_text('Add    another    Profile').click()
    self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set')), 2)
    self.assertEqual(self.selenium.find_elements_by_css_selector('.dynamic-profile_set')[1].get_attribute('id'), 'profile_set-1')
    self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set#profile_set-1    input[name=profile_set-1-first_name]')), 1)
    self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set#profile_set-1    input[name=profile_set-1-last_name]')), 1)
    self.selenium.find_element_by_link_text('Add    another    Profile').click()
    self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set')), 3)
    self.assertEqual(self.selenium.find_elements_by_css_selector('.dynamic-profile_set')[2].get_attribute('id'), 'profile_set-2')
    self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set#profile_set-2    input[name=profile_set-2-first_name]')), 1)
    self.assertEqual(len(self.selenium.find_elements_by_css_selector('.dynamic-profile_set#profile_set-2    input[name=profile_set-2-last_name]')), 1)
    self.selenium.find_element_by_name('profile_set-0-first_name').send_keys('0    first    name    1')
    self.selenium.find_element_by_name('profile_set-0-last_name').send_keys('0    last    name    2')
    self.selenium.find_element_by_name('profile_set-1-first_name').send_keys('1    first    name    1')
    self.selenium.find_element_by_name('profile_set-1-last_name').send_keys('1    last    name    2')
    self.selenium.find_element_by_name('profile_set-2-first_name').send_keys('2    first    name    1')
    self.selenium.find_element_by_name('profile_set-2-last_name').send_keys('2    last    name    2')
    self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
    self.wait_page_loaded()
    self.assertEqual(ProfileCollection.objects.all().count(), 1)
    self.assertEqual(Profile.objects.all().count(), 3)
