def testCreateCustomer(self):
        # Count the number of customers before creation.
        target_url = self.configuration['base_url'] + "/admin/order_manager/customer/"
        index_page = CustomerIndex(self.browser, target_url)

        num_customers_before_creation = index_page.count_customers()

        # Fill the form and submit it
        target_url = self.configuration['base_url'] + "/admin/order_manager/customer/add/"
        create_page = CustomerCreate(self.browser, target_url)
        first_name = self.configuration['customer_tests']['first_name']
        last_name = self.configuration['customer_tests']['last_name']
        create_page.fill_form(first_name, last_name)
        create_page.submit_form()

        # Verify that customer was created
        num_customers_after_creation = index_page.count_customers()
        self.validate((num_customers_after_creation == num_customers_before_creation + 1),
                      error_message="Could not find created customer.")

        customer_pattern = "([0-9]+) %s %s" % (first_name, last_name)
        customers_after_creation = index_page.get_customer_elements()
        # Regular expression match
        match = re.match(customer_pattern, customers_after_creation[0].text)
        self.validate((match is not None), error_message="Could not find created customer.")

        self.customer_id = index_page.id_for_customer_named(first_name, last_name)
    def testCreateCustomer(self):
        # Count the number of customers before creation.
        target_url = self.configuration[
            'base_url'] + "/admin/order_manager/customer/"
        index_page = CustomerIndex(self.browser, target_url)

        num_customers_before_creation = index_page.count_customers()

        # Fill the form and submit it
        target_url = self.configuration[
            'base_url'] + "/admin/order_manager/customer/add/"
        create_page = CustomerCreate(self.browser, target_url)
        first_name = self.configuration['customer_tests']['first_name']
        last_name = self.configuration['customer_tests']['last_name']
        create_page.fill_form(first_name, last_name)
        create_page.submit_form()

        # Verify that customer was created
        num_customers_after_creation = index_page.count_customers()
        self.validate((num_customers_after_creation
                       == num_customers_before_creation + 1),
                      error_message="Could not find created customer.")

        customer_pattern = "([0-9]+) %s %s" % (first_name, last_name)
        customers_after_creation = index_page.get_customer_elements()
        # Regular expression match
        match = re.match(customer_pattern, customers_after_creation[0].text)
        self.validate((match is not None),
                      error_message="Could not find created customer.")

        self.customer_id = index_page.id_for_customer_named(
            first_name, last_name)
    def testCreateCustomer(self):
        # Count the number of customers before creation.
        index_page = CustomerIndex(self.browser, self.configuration['base_url'])
        index_page.open()
        customers_before_creation = index_page.get_customer_elements()

        # Fill the form and submit it
        create_page = CustomerCreate(self.browser, self.configuration['base_url'])
        create_page.open()
        first_name = self.configuration['customer_tests']['first_name']
        last_name = self.configuration['customer_tests']['last_name']
        create_page.fill_form(first_name, last_name)
        create_page.submit_form()

        # Verify that customer was created
        customers_after_creation = index_page.get_customer_elements()
        assert len(customers_after_creation) == len(customers_before_creation) + 1, \
            "Could not find created customer."

        customer_pattern = "([0-9]+) %s %s" % (first_name, last_name)
        match = re.match(customer_pattern, customers_after_creation[0].text)
        assert match is not None, "Could not find created customer."

        self.customer_id = index_page.id_for_customer_named(first_name, last_name)