def generate_and_close(self): """Save this objects and close modal.""" self.button_generate_and_close = base.Button( self._driver, self._locator_button_generate) self.button_generate_and_close.click() selenium_utils.get_when_invisible(self._driver, self._locator_button_generate)
def _confirm_map_selected(self): """Select Map Selected button to confirm map selected objects to source object. """ base.Button(self._driver, self._locators.BUTTON_MAP_SELECTED).click() selenium_utils.get_when_invisible( self._driver, self._locators.BUTTON_MAP_SELECTED)
def select_month_start(self): """Select first day of current month.""" elements = self.get_day_els_current_month() elements[0].click() # wait for fadeout in case we're above some other element selenium_utils.get_when_invisible(self._driver, self._locator_datepcker) self.text = self.element.get_attribute("value")
def confirm_set_visible_fields(self): """Confirm set visible fields.""" _locator_set_fields = ( By.CSS_SELECTOR, self._locators.BUTTON_SET_FIELDS) Button(self._driver, _locator_set_fields).click_via_js() # issue GGRC-1854 selenium_utils.get_when_invisible(self._driver, _locator_set_fields)
def save_and_add_other(self): """Create object and open new Create modal.""" base.Button(self._driver, self._locators.BUTTON_SAVE_AND_ADD_ANOTHER).click() selenium_utils.get_when_invisible( self._driver, self._locators.BUTTON_SAVE_AND_ADD_ANOTHER) return self.__class__(self._driver)
def add_comments(self, *comments): """Add text comments to input field.""" for comment in comments: self.input_txt.enter_text(comment) self.add_btn.click() selenium_utils.get_when_invisible( self._driver, self._locators.CB_SPINNER_CSS) return self
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 save_and_add_other(self): """Save this objects and open a new modal.""" self.button_save_and_add_another = base.Button( self._driver, self._locator_button_add_another) self.button_save_and_add_another.click() selenium_utils.get_when_invisible(self._driver, self._locator_button_add_another) return self.__class__(self._driver)
def click_export_objs(self): """Click to 'Export Objects' button to confirm export objects according to selected before export format (Google Sheet or CSV). """ self.export_objs_btn.click() selenium_utils.get_when_invisible( self.export_page, self._locators.EXPORT_OBJECTS_SPINNER_CSS) selenium_utils.wait_for_js_to_load(self._driver)
def close_lhn_menu(self): """Closes LHN on Dashboard. """ try: self.toggle_lhn_menu.toggle(on_el=False) selenium_utils.get_when_invisible(self._driver, locator.LhnMenu.HOLDER) except exceptions.StaleElementReferenceException: self._refresh_elements() self.close_lhn_menu()
def open_add_new_ca_modal(self): """Open Add Attribute modal and return Custom Attribute Modal.""" selenium_utils.wait_until_stops_moving(self.button_add.element) selenium_utils.scroll_into_view(self._driver, self.button_add.element) selenium_utils.get_when_clickable(self._driver, self._locators.ADD_BTN) selenium_utils.get_when_invisible( self._driver, self._locators.TREE_SPINNER_CSS) self.button_add.click() return CustomAttributeModal(self._driver)
def _set_members_listed(self): """Wait for listed members to loaded and add them to local container.""" self._set_member_count() if self.member_count: # wait until the elements are loaded selenium_utils.get_when_invisible( self._driver, locator.ObjectWidget.LOADING) self.members_listed = self._driver.find_elements( *locator.ObjectWidget.MEMBERS_TITLE_LIST) else: self.members_listed = []
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 update_obj_ver_via_info_panel(self, src_obj, obj): """Open generic widget of mapped objects, select snapshotable object from Tree View by title and update object to latest version via Info panel. """ objs_widget = self.open_widget_of_mapped_objs(src_obj) obj_info_panel = ( objs_widget.tree_view.select_member_by_title(title=obj.title).panel) obj_info_panel.open_link_get_latest_ver().confirm_update() objs_widget.tree_view.wait_loading_after_actions() selenium_utils.get_when_invisible( self.driver, SnapshotedInfoPanel.locator_link_get_latest_ver)
def select_day_in_current_month(self, day): """Select day - sequential element from date picker. Days go from 0 to 28,29 or 30, depending on current month. Since we're selecting an element from list, we can pass e.g. -1 to select last day in month. Args: day (int) """ elements = self.get_day_els_current_month() elements[day].click() # wait for fadeout in case we're above some other element selenium_utils.get_when_invisible(self._driver, self._locator_datepcker) self.text = self.element.get_attribute("value")
def add_comments(self, *comments): """Add text comments to input field.""" count_of_comments = len(self.scopes) for comment in list(*comments): self.input_txt.enter_text(comment) self.add_btn.click() selenium_utils.get_when_invisible( self._driver, constants.locator.Common.SPINNER_CSS) count_of_comments += 1 try: selenium_utils.wait_until_condition( self._driver, lambda items: len(self.scopes) == count_of_comments) except exceptions.TimeoutException as err: raise (messages.ExceptionsMessages.err_comments_count.format( count_of_comments, len(self.scopes)) + err) return self
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 confirm_delete(self): """Confirm delete object.""" self.button_delete.click() selenium_utils.get_when_invisible(self._driver, self._locators.BUTTON_DELETE)
def confirm_update(self): """Confirm update object.""" selenium_utils.wait_for_js_to_load(self._driver) self.button_update.click() selenium_utils.get_when_invisible( self._driver, self._locators.BUTTON_CONFIRM)
def select_rand_day_in_curr_month(self): """Select random day in current month.""" random.choice(self.get_day_els_current_month()).click() # wait for fadeout in case we're above some other element selenium_utils.get_when_invisible(self._driver, self._locator_datepicker) self.text = self.element.get_attribute("value")
def _wait_until_invisible(self): for item_locator in self._locators: selenium_utils.get_when_invisible(self._driver, item_locator)
def _confirm_items_added(self): """Wait until items shown on Edit/Create Assessment Modal.""" selenium_utils.get_when_invisible( self._driver, locator.TreeView.NO_RESULTS_MSG_CSS)
def _confirm_items_added(self): """Wait until items shown on Edit/Create Assessment Modal.""" selenium_utils.get_when_invisible(self._driver, locator.TreeView.NO_RESULTS_MSG_CSS)
def confirm_update(self): """Confirm update object.""" self.button_update.click() selenium_utils.get_when_invisible(self._driver, self._locators.BUTTON_CONFIRM)
def save_and_close(self): """Create object and close Creation modal.""" self.button_save_and_close.click() selenium_utils.get_when_invisible(self._driver, self._locator_button_save)
def confirm_set_visible_fields(self): """Confirm set visible fields.""" _locator_set_fields = (By.CSS_SELECTOR, self._locators.BUTTON_SET_FIELDS) Button(self._driver, _locator_set_fields).click() selenium_utils.get_when_invisible(self._driver, _locator_set_fields)
def save_and_close(self): """Save this objects and close modal.""" self.button_save_and_close.click() selenium_utils.get_when_invisible(self._driver, self.locator_button_save)
def confirm_delete(self): """Confirm delete object.""" self.button_delete.click() selenium_utils.get_when_invisible( self._driver, self._locators.BUTTON_DELETE)
def _confirm_items_added(self): """Wait until items shown on Tree View""" selenium_utils.get_when_invisible(self._driver, locator.TreeView.NO_RESULTS_MESSAGE)