'Tests that a user can register.
This method will fail if you haven\'t created an admin and a facility.
(See CreateAdminMixin and CreateFacilityMixin.)'

def browser_register_user(self, username, password, first_name='firstname', last_name='lastname', facility_name=None, stay_logged_in=False):

    self.assertTrue(self._admin_exists(), 'No    admin    user    exists')
    self.assertTrue(self._facility_exists(), 'No    facility    exists')
    if (not stay_logged_in):
        self.browser_logout_user()
    register_url = self.reverse('facility_user_signup')
    self.browse_to(register_url)
    if (facility_name and self.browser.find_element_by_id('id_facility').is_displayed()):
        self.browser_activate_element('id_facility')
        self.browser_send_keys(facility_name)
    self.browser_activate_element(id='id_username')
    self.browser_form_fill(username)
    self.browser_form_fill(first_name)
    self.browser_form_fill(last_name)
    self.browser_form_fill(password)
    self.browser_form_fill(password)
    self.browser.find_element_by_id('id_username').submit()
