def save_and_close(self): """Edit object and close Edit modal.""" self.button_save_and_close.click() selenium_utils.wait_until_element_visible( self._driver, locator.Common.ALERT_SUCCESS_CSS) selenium_utils.wait_until_not_present( self._driver, self._locator_button_save)
def confirm_update(self): """Confirm updating an object.""" self.button_update.click() selenium_utils.wait_until_not_present(self._driver, locator.TreeView.ITEM_LOADING) selenium_utils.get_when_invisible(self._driver, locator.TreeView.SPINNER)
def wait_loading_after_actions(driver): """Wait loading elements of Tree View after made some action with object(s) under Tree View. """ selenium_utils.wait_until_not_present(driver, locator.TreeView.ITEM_LOADING) selenium_utils.get_when_invisible(driver, locator.TreeView.SPINNER)
def save_and_close(self): """Edit object and close Edit modal.""" self.button_save_and_close.click() selenium_utils.wait_until_element_visible( self._driver, locator.Common.ALERT_SUCCESS_CSS) selenium_utils.wait_until_not_present(self._driver, self._locator_button_save)
def wait_loading_after_actions(self): """Wait loading elements of Tree View after made some action with object(s) under Tree View. """ selenium_utils.wait_until_not_present( self._driver, self._locators.ITEM_LOADING) selenium_utils.get_when_invisible(self._driver, self._locators.SPINNER) selenium_utils.wait_for_js_to_load(self._driver)
def wait_loading_after_actions(self): """Wait loading elements of Tree View after made some action with object(s) under Tree View. """ selenium_utils.wait_until_not_present( self._driver, self._locators.ITEM_LOADING_CSS) selenium_utils.get_when_invisible( self._driver, self._locators.TREE_SPINNER_CSS) selenium_utils.wait_for_js_to_load(self._driver)
def save_and_close(self): """ Return: WidgetAdminCustomAttributes """ self.submit_btn.click() selenium_utils.wait_until_not_present( self._driver, self._locators.SAVE_AND_CLOSE_BTN_CSS) selenium_utils.wait_until_not_present( self._driver, self._locators.MODAL_CSS)
def open_add_new_ca_modal(self): """Open Add Attribute modal and return Custom Attribute Modal.""" selenium_utils.wait_until_stops_moving(self.add_btn.element) selenium_utils.scroll_into_view(self._driver, self.item_el) selenium_utils.get_when_clickable(self._driver, self._locators.ADD_BTN_CSS) selenium_utils.wait_until_not_present( self._driver, self._locators.TREE_SPINNER_CSS) self.add_btn.click() return CustomAttributeModal(self._driver)
def open_add_new_ca_modal(self): """Open Add Attribute modal and return Custom Attribute Modal.""" selenium_utils.wait_until_stops_moving(self.add_btn.element) selenium_utils.scroll_into_view(self._driver, self.item_el) selenium_utils.get_when_clickable(self._driver, self._locators.ADD_BTN_CSS) selenium_utils.wait_until_not_present( self._driver, self._locators.TREE_SPINNER_CSS) self.add_btn.click() return CustomAttributeModal(self._driver)
def save_and_close(self): """ Return: WidgetAdminCustomAttributes """ self.submit_btn.click() selenium_utils.wait_until_not_present( self._driver, self._locators.SAVE_AND_CLOSE_BTN_CSS) selenium_utils.wait_until_not_present(self._driver, self._locators.MODAL_CSS)
def get_tree_view_items_elements(self): """Get Tree View items as list of elements from current widget.""" _locator_items = (By.CSS_SELECTOR, self._locators.ITEMS.format(self.obj_name)) selenium_utils.get_when_invisible(self._driver, self._locators.SPINNER) selenium_utils.wait_until_not_present(self._driver, self._locators.ITEM_LOADING) self._tree_view_items_elements = selenium_utils.get_when_all_visible( self._driver, _locator_items)
def get_tree_view_items_elements(self): """Get tree view items as list of WebElements from the current widget. """ _locator_items = (By.CSS_SELECTOR, self._locators.ITEMS.format(self.obj_name)) selenium_utils.get_when_invisible(self._driver, self._locators.SPINNER) selenium_utils.wait_until_not_present( self._driver, self._locators.ITEM_LOADING) self._tree_view_items_elements = selenium_utils.get_when_all_visible( self._driver, _locator_items)
def _log_tab_validate(_driver, log_panel_element): """Validation of all log items on Log pane. Return: list of dicts. """ tab_elements = element.AsmtLogTab tab_locators = locator.AssessmentLogTab selenium_utils.wait_for_js_to_load(_driver) def check_log_item(log_element): """Check consistency of log item by passed log element. Return: dict of bool. """ all_cells_texts = [ elem.text for elem in log_element.find_elements(*tab_locators.CELLS_CSS) ] expected_headers = [ tab_elements.FIELD, tab_elements.ORIGINAL_VALUE, tab_elements.NEW_VALUE ] headers_is_valid = ([ all_cells_texts.pop(0) for _ in xrange(len(expected_headers)) ] == expected_headers) field_is_valid = all( cell != "" and cell != tab_elements.EMPTY_STATEMENT for cell in all_cells_texts[0::3]) orignal_value_is_valid = all(cell == tab_elements.EMPTY_STATEMENT for cell in all_cells_texts[1::3]) new_value_is_valid = all( cell != "" and cell != tab_elements.EMPTY_STATEMENT for cell in all_cells_texts[2::3]) person_element = log_element.find_element( *tab_locators.COMMENT_PERSON_CSS) return { "headers_is_valid": headers_is_valid, "field_is_valid": field_is_valid, "orignal_value_is_valid": orignal_value_is_valid, "new_value_is_valid": new_value_is_valid, "person_is_valid": (person_element.text == roles.DEFAULT_USER_EMAIL) } selenium_utils.wait_until_not_present(_driver, locator.Common.SPINNER_CSS) log_list = selenium_utils.get_when_all_visible( log_panel_element, tab_locators.LOG_LIST_CSS) return [check_log_item(el) for el in log_list]
def __init__(self, driver, info_widget_cls, obj_name): super(TreeView, self).__init__(driver, obj_name) self.info_widget_cls = info_widget_cls self.obj_name = obj_name self.dropdown_settings_cls = factory.get_cls_3bbs_dropdown_settings( object_name=obj_name) self.dropdown_tree_view_item_cls = factory.get_cls_dropdown_tree_view_item( object_name=obj_name) self.fields_to_set = factory.get_fields_to_set(object_name=obj_name) self.locator_set_visible_fields = self._locators.SHOW_FIELDS_BTN_CSS selenium_utils.wait_until_not_present( self._driver, locator.Common.SPINNER_CSS)
def __init__(self, driver, info_widget_cls, obj_name): super(TreeView, self).__init__(driver, obj_name) self.info_widget_cls = info_widget_cls self.obj_name = obj_name self.dropdown_settings_cls = factory.get_cls_3bbs_dropdown_settings( object_name=obj_name, is_tree_view_not_info=True) self.dropdown_tree_view_item_cls = factory.get_cls_dropdown_tree_view_item( object_name=obj_name) self.fields_to_set = factory.get_fields_to_set(object_name=obj_name) self.locator_set_visible_fields = self._locators.SHOW_FIELDS_BTN_CSS selenium_utils.wait_until_not_present(self._driver, locator.Common.SPINNER_CSS)
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 __init__(self, driver, info_widget_cls, obj_name, is_versions_widget): super(TreeView, self).__init__(driver, obj_name, is_versions_widget) self.info_widget_cls = info_widget_cls self.obj_name = obj_name self.is_versions_widget = is_versions_widget self.create_obj_cls = factory.get_cls_create_obj(object_name=obj_name) self.dropdown_settings_cls = factory.get_cls_3bbs_dropdown_settings( object_name=obj_name, is_tree_view_not_info=True) self.dropdown_tree_view_item_cls = factory.get_cls_dropdown_tree_view_item( object_name=obj_name) self.fields_to_set = factory.get_fields_to_set(object_name=obj_name) self.locator_set_visible_fields = ( By.CSS_SELECTOR, self._locators.BUTTON_SHOW_FIELDS.format(self.widget_name)) selenium_utils.wait_until_not_present(self._driver, locator.Common.SPINNER_CSS)
def changelog_tab_validate(_driver, log_panel_element): """Validation of all log items on Log pane. Return: list of dicts. """ tab_elements = element.AsmtLogTab tab_locators = locator.AssessmentLogTab selenium_utils.wait_for_js_to_load(_driver) def check_log_item(log_element): """Check consistency of log item by passed log element. Return: dict of bool. """ all_cells_texts = [elem.text for elem in log_element.find_elements(*tab_locators.CELLS_CSS)] expected_headers = [tab_elements.FIELD, tab_elements.ORIGINAL_VALUE, tab_elements.NEW_VALUE] headers_is_valid = ( [all_cells_texts.pop(0) for _ in xrange(len(expected_headers))] == expected_headers) field_is_valid = all( cell != "" and cell != tab_elements.EMPTY_STATEMENT for cell in all_cells_texts[0::3]) orignal_value_is_valid = all( cell == tab_elements.EMPTY_STATEMENT for cell in all_cells_texts[1::3]) new_value_is_valid = all( cell != "" and cell != tab_elements.EMPTY_STATEMENT for cell in all_cells_texts[2::3]) person_element = log_element.find_element( *tab_locators.COMMENT_PERSON_CSS) return {"headers_is_valid": headers_is_valid, "field_is_valid": field_is_valid, "orignal_value_is_valid": orignal_value_is_valid, "new_value_is_valid": new_value_is_valid, "person_is_valid": ( person_element.text == users.FAKE_SUPER_USER.email) } selenium_utils.wait_until_not_present( _driver, locator.Common.SPINNER_CSS) log_list = selenium_utils.get_when_all_visible( log_panel_element, tab_locators.LOG_LIST_CSS) return [check_log_item(el) for el in log_list]
def _set_tree_view_items(self): """Set tree view items list with TreeViewItem objects from the current widget. """ items_locator = (By.CSS_SELECTOR, self._locator.ITEMS.format(self.object_name)) selenium_utils.get_when_invisible(self._driver, self._locator.SPINNER) selenium_utils.wait_until_not_present(self._driver, self._locator.ITEM_LOADING) elements = selenium_utils.get_when_all_visible(self._driver, items_locator) self._tree_view_items = [ TreeViewItem(driver=self._driver, text=el.text, expand_btn=el.find_element( By.CSS_SELECTOR, self._locator.ITEM_EXPAND_BUTTON)) for el in elements ]
def wait_loading_after_actions(self): """Wait loading elements of Tree View after made some action with object(s) under Tree View. """ from lib.utils.test_utils import wait_for selenium_utils.wait_until_not_present( self._driver, self._locators.ITEM_LOADING_CSS) selenium_utils.get_when_invisible( self._driver, self._locators.TREE_SPINNER_CSS) if "MAPPER_TREE_SPINNER_NO_RESULT" in self._locators.__dict__: 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 wait_for(is_result_ready) selenium_utils.wait_for_doc_is_ready(self._driver) selenium_utils.wait_for_js_to_load(self._driver)
def wait_loading_after_actions(self): """Wait loading elements of Tree View after made some action with object(s) under Tree View. """ from lib.utils.test_utils import wait_for selenium_utils.wait_until_not_present(self._driver, self._locators.ITEM_LOADING_CSS) selenium_utils.get_when_invisible(self._driver, self._locators.TREE_SPINNER_CSS) if "MAPPER_TREE_SPINNER_NO_RESULT" in self._locators.__dict__: 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 wait_for(is_result_ready) selenium_utils.wait_for_doc_is_ready(self._driver) selenium_utils.wait_for_js_to_load(self._driver)
def confirm_update(self): """Confirm updating an object.""" self.button_update.click() selenium_utils.wait_until_not_present(self._driver, locator.TreeView.ITEM_LOADING) selenium_utils.get_when_invisible(self._driver, locator.TreeView.SPINNER)
def save_and_close(self): """Create object and close Creation modal.""" self.button_save_and_close.click() selenium_utils.wait_until_not_present( self._driver, self._locator_button_save)
def save_and_close(self): """Edit object and close Edit modal.""" self.button_save_and_close.click() selenium_utils.wait_until_not_present(self._driver, self._locator_button_save)
def save_and_close(self): """Create person and close Creation modal.""" self.button_save_and_close.click() selenium_utils.wait_until_not_present( self._driver, self._locators.BUTTON_SAVE_AND_CLOSE)
def close(self): """Close modal window.""" self.close_btn.click() selenium_utils.wait_until_not_present(self._driver, self._locators.MODAL_CSS)
def close_modal(self): """Close Unified Mapper's modal window.""" self.close_btn.click() selenium_utils.wait_until_not_present( self._driver, self._locators.MODAL_CSS)