Ejemplo n.º 1
0
    def get_permissions_using_url(self, reward_id):
        """return the access level status for by calling the urls end point for reward"""
        permission_list = {}
        try:
            config = get_config()
            reward_list_url = config['url'] + '/p/rewards/list'
            self.browser.get(reward_list_url)
            ensure_page_safe(self.browser)
            permission_list['read'] = False
            if find_element(self.browser, self.list_table):
                table = self.read_table()
                if len(table) > 0:
                    permission_list['read'] = True

            permission_list['create'] = True if find_element(self.browser, self.create_new) else False
            reward_create_url = config['url'] + '/p/rewards/create'
            self.browser.get(reward_create_url)
            ensure_page_safe(self.browser)
            permission_list['create'] = True if find_element(self.browser, self.create_new) else False

            reward_resource_url = config['url'] + '/p/rewards/show/{}'.format(reward_id)
            self.browser.get(reward_resource_url)
            ensure_page_safe(self.browser)
            permission_list['update'] = True if find_element(self.browser, self.edit_button) else False
            return permission_list
        except NoSuchElementException:
            return permission_list
Ejemplo n.º 2
0
 def check_error_message(self):
     """return the error message assertion status"""
     next_button = self.browser.find_element(*self.next_button)
     custom_click(self.browser, next_button)
     end_date = self.browser.find_element(*self.end_date_input)
     move_to_element(self.browser, end_date)
     return find_element(self.browser, self.mandatory_error_message)
Ejemplo n.º 3
0
 def check_error_message(self, input_data):
     """return the error message assertion status"""
     next_button = self.browser.find_element(*self.next_button)
     custom_click(self.browser, next_button)
     assertion = find_element(self.browser, self.mandatory_error_message)
     self.browser.find_element(*self.name).send_keys(input_data['Name'])
     custom_click(self.browser, next_button)
     return assertion
 def get_api_end_point_status_with_url(self):
     """return the status list by hitting the multiple web-points on the browser"""
     status_list = {}
     config = get_config()
     base_url = config['url']
     for end_point in self.urls_enpoints:
         self.browser.get(base_url + '/p' + end_point)
         ensure_page_safe(self.browser)
         forbidden_page = ForbiddenPage(self.browser)
         if find_element(self.browser, forbidden_page.header):
             status_list[end_point] = 'No Access'
         else:
             if find_element(self.browser, self.list_table):
                 if len(read_table(self.browser, self.list_table)) == 0:
                     status_list[end_point] = 'No Access'
                 else:
                     status_list[end_point] = 'Access'
             else:
                 status_list[end_point] = 'Access'
     return status_list
Ejemplo n.º 5
0
 def get_permissions(self):
     """return the permissions for the create, read and update reward"""
     permission_list = {}
     try:
         rewards_panel = self.browser.find_element(*self.rewards)
         rewards_panel.click()
         wait_for_element_displayed(self.browser.find_element(*self.list_table))
         wait_for(lambda: len(self.read_table()) > 0, delay=1, num_sec=5)
         table = self.read_table()
         if len(table) > 0:
             permission_list['read'] = True
         else:
             permission_list['read'] = False
         permission_list['create'] = True if find_element(self.browser, self.create_new) else False
         element = self.get_first_row_from_table()
         self._navigate_to_edit_page(element)
         permission_list['update'] = True if find_element(self.browser, self.edit_button) else False
         return permission_list
     except NoSuchElementException:
         return permission_list
 def get_left_panel_links(self):
     """return the list containing 'Access' or 'No Access' for the links from left panel"""
     status_list = {}
     link_list = (self.reports, self.rewards, self.catalogs, self.campaigns, self.loyalties,
                  self.merchants, self.customer_management, self.bulk_actions, self.settings,
                  self.business_intelligence)
     for link in link_list:
         if find_element(self.browser, link):
             status_list[link[1]] = 'Access'
         else:
             status_list[link[1]] = 'No Access'
     return status_list
Ejemplo n.º 7
0
 def get_permissions(self):
     """get permissions for bulk action functionality"""
     permission_list = {}
     try:
         bulk_action_panel = self.browser.find_element(*self.bulk_actions)
         bulk_action_panel.click()
         permission_list['create'] = True if find_element(
             self.browser, self.upload_button) else False
         permission_list['read'] = self.read_table()
         return permission_list
     except NoSuchElementException:
         return permission_list
Ejemplo n.º 8
0
 def check_sections_after_disable_on_ui(self):
     """check that sections are disable correctly and return the result"""
     self.navigate_to_reward_create_page()
     elements = self.browser.find_elements(*self.switcher_button)
     for element in elements:
         move_to_element(self.browser, element)
         custom_click(self.browser, element)
     for locator in (self.upload_file_button, self.create_merchant, self.add_selling_price):
         if find_element(self.browser, locator):
             return False
         else:
             return True
Ejemplo n.º 9
0
    def get_field_access_status(self, input_data):
        """return the field access assertion status"""
        field_status_dict = {}
        if 'Type' in input_data:
            if input_data['Type'].lower() in ('public', 'private', 'system'):
                reward_type = self.select_reward_type(input_data['Type'])
                self.browser.find_element(*reward_type).click()
            else:
                raise Exception("Not a valid reward type ! ")

        for attribute, locator in [('Brands', self.brands),
                                   ('Tags', self.tags),
                                   ('Catalogues', self.catalogues),
                                   ('Labels', self.labels),
                                   ('Categories', self.categories)]:
            if find_element(self.browser, locator):
                field_status_dict[attribute] = True
            else:
                field_status_dict[attribute] = False
        return field_status_dict
Ejemplo n.º 10
0
 def on_bulk_action_page(self):
     """check on the bulk action page """
     return find_element(self.browser, self.bulk_actions)
Ejemplo n.º 11
0
 def on_reward_page(self):
     """check if are already on rewards page"""
     return find_element(self.browser, self.rewards)