def is_result_ready(): """Check if the results on mapper is ready.""" is_results_ready = False if not selenium_utils.is_element_enabled( selenium_utils.get_when_visible( self._driver, constants.locator.CommonModalUnifiedMapper.BUTTON_SEARCH) ): return is_results_ready if ( selenium_utils.is_element_exist( self._driver, self._locators.MAPPER_TREE_SPINNER_NO_RESULT) or selenium_utils.is_element_exist( self._driver, self._locators.MAPPER_TREE_SPINNER_ITEMS) ): return is_results_ready if ( selenium_utils.is_element_exist( self._driver, self.locator_no_results_message) or selenium_utils.get_when_all_visible( self._driver, (By.CSS_SELECTOR, self._locators.ITEMS)) ): is_results_ready = True return is_results_ready return is_results_ready
def _add_obj_review_to_lsopes(self): """Extend list of scopes by object review section """ review_msg = None if selenium_utils.is_element_exist(self._driver, self._locators.REVIEW_REJECTED_TXT): review_msg = self._driver.find_element(*self._locators. REVIEW_REJECTED_TXT).text elif selenium_utils.is_element_exist(self._driver, self._locators.REVIEW_APPROVED_TXT): review_msg = self._driver.find_element(*self._locators. REVIEW_APPROVED_TXT).text self._extend_list_all_scopes(self._elements.OBJECT_REVIEW_FULL, review_msg)
def is_link_get_latest_ver_exist(self): """Find link get latest version under Info panel. Return: True if link get latest version is exist, False if link get latest version is not exist. """ return selenium_utils.is_element_exist( self.info_widget_elem, self.locator_link_get_latest_ver)
def is_link_get_latest_ver_exist(self): """Find link get latest version under Info panel. Return: True if link get latest version is exist, False if link get latest version is not exist. """ return selenium_utils.is_element_exist( self._driver, locator.CommonWidgetInfoSnapshots.LINK_GET_LAST_VER)
def get_review_state_txt(self): """Get object's review state text from Info Widget checking if exact UI elements are existed. """ return (element.ReviewStates.REVIEWED if selenium_utils.is_element_exist( self.info_widget_elem, self._locators.TXT_OBJECT_REVIEWED) else element.ReviewStates.UNREVIEWED)
def __init__(self, driver): super(Assessments, self).__init__(driver) self.title_lbl = self.get_title_lbl_txt() self.is_verified_lbl_txt = self._elements.VERIFIED.upper() self.is_verified = selenium_utils.is_element_exist( self.info_widget_elem, self._locators.ICON_VERIFIED) self.mapped_objects_lbl_txt = self._elements.MAPPED_OBJECTS.upper() self.mapped_objects_titles_txt = self._get_mapped_objs_titles_txt() self.lcas_scope_txt = self.get_headers_and_values_dict_from_cas_scopes( is_gcas_not_lcas=False) self.creators_lbl_txt, self.creators_txt = ( self.get_header_and_value_txt_from_people_scopes( self._elements.CREATORS.upper())) self.assignees_lbl_txt, self.assignees_txt = ( self.get_header_and_value_txt_from_people_scopes( self._elements.ASSIGNEES.upper())) self.verifiers_lbl_txt, self.verifiers_txt = ( self.get_header_and_value_txt_from_people_scopes( self._elements.VERIFIERS.upper())) self.comments_panel = base.CommentsPanel(self.info_widget_elem, self._locators.COMMENTS_CSS) self.comments_lbl_txt = self.comments_panel.header_lbl.text self.comments_scopes_txt = self.comments_panel.scopes # todo: implement separate add lcas and gcas # todo: implement separate add mapped ctrls and mapped other objs self._extend_list_all_scopes([ self.is_verified_lbl_txt, self.creators_lbl_txt, self.assignees_lbl_txt, self.verifiers_lbl_txt, self.mapped_objects_lbl_txt, self.comments_lbl_txt ], [ self.is_verified, self.creators_txt, self.assignees_txt, self.verifiers_txt, self.mapped_objects_titles_txt, self.comments_scopes_txt ])
def _tabs(self): """If dashboard controller exists set 'tab' items to actual tabs. Else set 'tab' items to only one active item. - Return: dict of tab members """ if selenium_utils.is_element_exist(self._driver, self._locators.TAB_CONTROLLER_CSS): tabs = {tab_el.text: self.active_tab_elem for tab_el in self.tab_controller.get_items()} else: tabs = {value_aliases.DEFAULT: self.active_tab_elem} return tabs
def get_tree_view_items_elements(self): """Get Tree View items as list of elements from current widget. If no items in tree view return empty list. """ _locator_items = (By.CSS_SELECTOR, self._locators.ITEMS) self.wait_loading_after_actions() has_no_record_found = selenium_utils.is_element_exist( self._driver, self.locator_no_results_message) self._tree_view_items_elements = ([] if has_no_record_found else selenium_utils.get_when_all_visible( self._driver, _locator_items)) return self._tree_view_items_elements
def get_tree_view_items_elements(self): """Get Tree View items as list of elements from current widget. If no items in tree view return empty list. """ _locator_items = ( By.CSS_SELECTOR, self._locators.ITEMS) self.wait_loading_after_actions() has_no_record_found = selenium_utils.is_element_exist( self._driver, self.locator_no_results_message) self._tree_view_items_elements = ( [] if has_no_record_found else selenium_utils.get_when_all_visible(self._driver, _locator_items)) return self._tree_view_items_elements
def is_info_page(self): """Check is the current page is Info Page and not Info Panel according to checking existing of element by locator and URL's logic.""" is_info_page = False if selenium_utils.is_element_exist( self._driver, (By.XPATH, constants.locator.Common.INFO_PAGE_XPATH) ): if ((self.widget_name_from_url in url.Widget.INFO) or ((objects.get_singular(self.source_obj_from_url) == self.mapped_obj_from_url) and (self.source_obj_id_from_url == self.mapped_obj_id_from_url)) or (self.widget_name_from_url == self.mapped_obj_from_url == self.mapped_obj_id_from_url == "")): is_info_page = True return is_info_page
def get_tree_view_items_elements(self): """Get Tree View items as list of elements from current widget. If no items in tree view return empty list. """ _locator_items = (By.CSS_SELECTOR, self._locators.ITEMS.format(self.widget_name)) selenium_utils.get_when_invisible(self._driver, self._locators.SPINNER) selenium_utils.wait_until_not_present(self._driver, self._locators.ITEM_LOADING) selenium_utils.wait_for_js_to_load(self._driver) has_no_record_found = selenium_utils.is_element_exist( self._driver, self._locators.NO_RESULTS_MESSAGE) self._tree_view_items_elements = ([] if has_no_record_found else selenium_utils.get_when_all_visible( self._driver, _locator_items))
def is_info_page(self): """Check is the current page is Info Page and not Info Panel according to checking existing of element by locator and URL's logic.""" is_info_page = False if selenium_utils.is_element_exist( self._driver, (By.XPATH, constants.locator.Common.INFO_PAGE_XPATH) ): if ((self.widget_name_from_url == WidgetBar.INFO.lower()) or ((objects.get_singular(self.source_obj_from_url) == self.mapped_obj_from_url) and (self.source_obj_id_from_url == self.mapped_obj_id_from_url)) or (self.widget_name_from_url == self.mapped_obj_from_url == self.mapped_obj_id_from_url == "")): is_info_page = True return is_info_page
def _init_tree_view_items(self): """Init Tree View items as list of TreeViewItem from current widget. If no items in tree view return empty list. """ _locator_items = (By.CSS_SELECTOR, self._locators.ITEMS) self.wait_loading_after_actions() has_no_record_found = selenium_utils.is_element_exist( self._driver, self.locator_no_results_message) self._tree_view_items = ([] if has_no_record_found else [ TreeViewItem(driver=self._driver, locator_or_element=element, item_btn_locator=(By.CSS_SELECTOR, self._locators.ITEM_EXPAND_BTN)) for element in selenium_utils.get_when_all_visible( self._driver, _locator_items) ]) return self._tree_view_items
def _init_tree_view_items(self): """Init Tree View items as list of TreeViewItem from current widget. If no items in tree view return empty list. """ _locator_items = ( By.CSS_SELECTOR, self._locators.ITEMS) self.wait_loading_after_actions() has_no_record_found = selenium_utils.is_element_exist( self._driver, self.locator_no_results_message) self._tree_view_items = ( [] if has_no_record_found else [ TreeViewItem( driver=self._driver, locator_or_element=element, item_btn_locator=( By.CSS_SELECTOR, self._locators.ITEM_EXPAND_BTN)) for element in selenium_utils.get_when_all_visible( self._driver, _locator_items)]) return self._tree_view_items
def __init__(self, driver): super(Assessments, self).__init__(driver) self.title_lbl = self.get_title_lbl_txt() self.is_verified_lbl_txt = self._elements.VERIFIED.upper() self.is_verified = selenium_utils.is_element_exist( self.info_widget_elem, self._locators.ICON_VERIFIED) self.workflow_container = tab_containers.AssessmentTabContainer( self._driver, self.info_widget_elem.find_element( *self._locators.ASMT_TAB_CONTAINER_CSS)) self.workflow_container.tab_controller.active_tab = ( element.AssessmentTabContainer.ASMT_TAB) self.mapped_objects_lbl_txt = self._elements.MAPPED_OBJECTS.upper() self.mapped_objects_titles_txt = self._get_mapped_objs_titles_txt() self.lcas_scope_txt = self.get_headers_and_values_dict_from_cas_scopes( is_gcas_not_lcas=False) self.creators_lbl_txt, self.creators_txt = ( self.get_header_and_value_txt_from_custom_scopes( self._elements.CREATORS_.upper(), self._locators.PEOPLE_HEADERS_AND_VALUES)) self.assignees_lbl_txt, self.assignees_txt = ( self.get_header_and_value_txt_from_custom_scopes( self._elements.ASSIGNEES_.upper(), self._locators.PEOPLE_HEADERS_AND_VALUES)) self.verifiers_lbl_txt, self.verifiers_txt = ( self.get_header_and_value_txt_from_custom_scopes( self._elements.VERIFIERS_.upper(), self._locators.PEOPLE_HEADERS_AND_VALUES)) self.comments_panel = base.CommentsPanel(self.info_widget_elem, self._locators.COMMENTS_CSS) self.comments_lbl_txt = self.comments_panel.header_lbl.text self.comments_scopes_txt = self.comments_panel.scopes # todo: implement separate add lcas and gcas # todo: implement separate add mapped ctrls and mapped other objs self._extend_list_all_scopes([ self.is_verified_lbl_txt, self.creators_lbl_txt, self.assignees_lbl_txt, self.verifiers_lbl_txt, self.mapped_objects_lbl_txt, self.comments_lbl_txt ], [ self.is_verified, self.creators_txt, self.assignees_txt, self.verifiers_txt, self.mapped_objects_titles_txt, self.comments_scopes_txt ])
def __init__(self, driver): super(Assessments, self).__init__(driver) self.is_verified_lbl_txt = self._elements.VERIFIED.upper() self.is_verified = selenium_utils.is_element_exist( self.info_widget_elem, self._locators.ICON_VERIFIED) self.asmt_type_lbl_txt = self._elements.ASMT_TYPE.upper() self.asmt_type = base.Label( self.info_widget_elem, self._locators.ASMT_TYPE_CSS) self.asmt_type_txt = objects.get_obj_type(self.asmt_type.text) self.mapped_objects_lbl_txt = self._elements.MAPPED_OBJECTS.upper() self.mapped_objects_titles_txt = self._get_mapped_objs_titles_txt() self.lcas_scope_txt = self.get_headers_and_values_dict_from_cas_scopes( is_gcas_not_lcas=False) self.creators_lbl_txt, self.creators_txt = ( self.get_header_and_value_txt_from_people_scopes( self._elements.CREATORS.upper())) self.assignees_lbl_txt, self.assignees_txt = ( self.get_header_and_value_txt_from_people_scopes( self._elements.ASSIGNEES.upper())) self.verifiers_lbl_txt, self.verifiers_txt = ( self.get_header_and_value_txt_from_people_scopes( self._elements.VERIFIERS.upper())) self.comments_panel = base.CommentsPanel( self.info_widget_elem, self._locators.COMMENTS_CSS) self.comments_lbl_txt = self.comments_panel.header_lbl.text self.comments_scopes_txt = self.comments_panel.scopes self._assessment_tab_name = "Assessment" self._other_attributes_tab_name = "Other Attributes" # todo: implement separate add lcas and gcas # todo: implement separate add mapped ctrls and mapped other objs self._extend_list_all_scopes( [self.is_verified_lbl_txt, self.creators_lbl_txt, self.assignees_lbl_txt, self.verifiers_lbl_txt, self.mapped_objects_lbl_txt, self.comments_lbl_txt, self.asmt_type_lbl_txt], [self.is_verified, self.creators_txt, self.assignees_txt, self.verifiers_txt, self.mapped_objects_titles_txt, self.comments_scopes_txt, self.asmt_type_txt])
def __init__(self, driver): super(Assessments, self).__init__(driver) self.is_verified_lbl_txt = self._elements.VERIFIED.upper() self.is_verified = selenium_utils.is_element_exist( self.info_widget_elem, self._locators.ICON_VERIFIED) self.asmt_type_lbl_txt = self._elements.ASMT_TYPE.upper() self.asmt_type = base.Label(self.info_widget_elem, self._locators.ASMT_TYPE_CSS) self.asmt_type_txt = objects.get_obj_type(self.asmt_type.text) self.mapped_objects_lbl_txt = self._elements.MAPPED_OBJECTS.upper() self.mapped_objects_titles_txt = self._get_mapped_objs_titles_txt() self.creators_lbl_txt, self.creators_txt = ( self.get_header_and_value_txt_from_people_scopes( self._elements.CREATORS.upper())) self.assignees_lbl_txt, self.assignees_txt = ( self.get_header_and_value_txt_from_people_scopes( self._elements.ASSIGNEES.upper())) self.verifiers_lbl_txt, self.verifiers_txt = ( self.get_header_and_value_txt_from_people_scopes( self._elements.VERIFIERS.upper())) self.comments_panel = base.CommentsPanel(self.info_widget_elem, self._locators.COMMENTS_CSS) self.comments_lbl_txt = self.comments_panel.header_lbl.text self.comments_scopes_txt = self.comments_panel.scopes self._assessment_tab_name = "Assessment" self._other_attributes_tab_name = "Other Attributes" # todo: implement separate add mapped ctrls and mapped other objs self._extend_list_all_scopes([ self.is_verified_lbl_txt, self.creators_lbl_txt, self.assignees_lbl_txt, self.verifiers_lbl_txt, self.mapped_objects_lbl_txt, self.comments_lbl_txt, self.asmt_type_lbl_txt ], [ self.is_verified, self.creators_txt, self.assignees_txt, self.verifiers_txt, self.mapped_objects_titles_txt, self.comments_scopes_txt, self.asmt_type_txt ])
def __init__(self, driver): super(Assessments, self).__init__(driver) self.verified = selenium_utils.is_element_exist( self._driver, self._locators.ICON_VERIFIED) self.workflow_container = tab_containers.AssessmentTabContainer( self._driver, self._driver.find_element(*self._locators.ASMT_TAB_CONTAINER_CSS)) self.workflow_container.switch_to_tab( element.AssessmentTabContainer.ASMT_TAB) self.mapped_objects_titles_and_descriptions = self._driver.find_elements( *self._locators.MAPPED_OBJECTS_TITLES_AND_DESCRIPTIONS) self.mapped_objects_titles_text = [ mapped_el.find_element(*self._locators.MAPPED_OBJECT_TITLE).text for mapped_el in self.mapped_objects_titles_and_descriptions ] self.mapped_objects_descriptions_text = [ mapped_el.find_element( *self._locators.MAPPED_OBJECT_DESCRIPTION).text for mapped_el in self.mapped_objects_titles_and_descriptions ] self.lcas_text = self.get_headers_and_values_dict_from_cas_scopes( is_gcas_not_lcas=False) self.creators_text, self.creators_entered_text = ( self.get_header_and_value_text_from_custom_scopes( self._elements.CREATORS_.upper(), self._locators.PEOPLE_HEADERS_AND_VALUES)) self.assignees_text, self.assignees_entered_text = ( self.get_header_and_value_text_from_custom_scopes( self._elements.ASSIGNEES_.upper(), self._locators.PEOPLE_HEADERS_AND_VALUES)) self.verifiers_text, self.verifiers_entered_text = ( self.get_header_and_value_text_from_custom_scopes( self._elements.VERIFIERS_.upper(), self._locators.PEOPLE_HEADERS_AND_VALUES)) self.comments = base.CommentsPanel(self._driver, self._locators.COMMENTS_CSS) self.comments_scopes = self.comments.scopes
def is_edit_exist(self): """Find edit button in 3BBS dropdown modal. Return: True if edit button is exist, False if edit button is not exist. """ return selenium_utils.is_element_exist(self._driver, self.edit_locator)
def is_dashboard_tab_exist(self): """Check is 'Dashboard' tab exist on Object Widget Bar.""" return selenium_utils.is_element_exist( self._driver, locator.WidgetBar.DASHBOARD_TAB)
def is_add_tab_present(self): """Checks presence of Add Tab""" return selenium_utils.is_element_exist(self._driver, locator.WidgetBar.BUTTON_ADD)
def __init__(self, driver): super(Assessments, self).__init__(driver) self.workflow_container = tab_containers.AssessmentTabContainer( self._driver, self._driver.find_element(*self._locators.ASMT_TAB_CONTAINER_CSS)) self.workflow_container.switch_to_default_tab() self.code_section = base.Label(self._driver, self._locators.CODE_CSS) # mapped objects self.mapped_objects_titles_and_descriptions = self._driver.find_elements( *self._locators.MAPPED_OBJECTS_TITLES_AND_DESCRIPTIONS) self.mapped_objects_titles_text = [ mapped_el.find_element(*self._locators.MAPPED_OBJECT_TITLE).text for mapped_el in self.mapped_objects_titles_and_descriptions ] self.mapped_objects_descriptions_text = [ mapped_el.find_element( *self._locators.MAPPED_OBJECT_DESCRIPTION).text for mapped_el in self.mapped_objects_titles_and_descriptions ] # LCAs and GCAs self.cas_text = self.get_headers_and_values_dict_from_cas_scopes() self.cas_text.update( self.get_headers_and_values_dict_from_cas_scopes( is_gcas_not_lcas=False)) # people section self.creators_text, self.creators_entered_text = ( self.get_header_and_value_text_from_custom_scopes( self._elements.CREATORS_.upper(), self._locators.PEOPLE_HEADERS_AND_VALUES)) self.assignees_text, self.assignees_entered_text = ( self.get_header_and_value_text_from_custom_scopes( self._elements.ASSIGNEES_.upper(), self._locators.PEOPLE_HEADERS_AND_VALUES)) self.verifiers_text, self.verifiers_entered_text = ( self.get_header_and_value_text_from_custom_scopes( self._elements.VERIFIERS_.upper(), self._locators.PEOPLE_HEADERS_AND_VALUES)) self.verified = (selenium_utils.is_element_exist( self._driver, self._locators.ICON_VERIFIED)) # code section self.code_text = (self.code_section.element.find_element( *self._locators.CODE_HEADER_CSS).text) self.code_entered_text = (self.code_section.element.find_element( *self._locators.CODE_VALUE_CSS).text) # comments section self.comments = base.CommentsPanel(self._driver, self._locators.COMMENTS_CSS) # scope self.list_all_headers_text = [ self._elements.CAS.upper(), self._elements.TITLE, self._elements.STATE.upper(), self._elements.VERIFIED.upper(), self.creators_text, self.assignees_text, self.verifiers_text, self._elements.MAPPED_OBJECTS.upper(), self.code_text, self.comments.header_lbl.text ] self.list_all_values_text = [ self.cas_text, self.title_entered().text, objects.get_normal_form(self.state().text), self.verified, self.creators_entered_text, self.assignees_entered_text, self.verifiers_entered_text, self.mapped_objects_titles_text, self.code_entered_text, self.comments.scopes ]
def is_dashboard_tab_exist(self): """Check is 'Dashboard' tab exist on Object Widget Bar.""" return selenium_utils.is_element_exist(self._driver, locator.WidgetBar.DASHBOARD_TAB)