def test_invite_existing_user(self): ''' Create user and VF, login, invite existing user, login with second user and verify user has joined to engagement ''' user_content = API.VirtualFunction.create_engagement( wait_for_gitlab=False) second_user_content = API.VirtualFunction.create_engagement( wait_for_gitlab=False) activationUrl = DB.User.get_activation_url(user_content['email']) Frontend.General.re_open(activationUrl) Frontend.User.login(user_content['email'], Constants.Default.Password.TEXT) vfFullName = user_content[ 'engagement_manual_id'] + ": " + user_content['vfName'] actualVfNameid = "clickable-" + vfFullName Click.id(actualVfNameid, wait_for_page=True) Wait.id(Constants.Dashboard.Overview.TeamMember.ID) Frontend.Wizard.invite_team_members_modal(second_user_content['email']) enguuid = DB.General.select_where( "uuid", "ice_engagement", "engagement_manual_id", user_content['engagement_manual_id'], 1) # Fetch one is_service_provider_contact user ID. invitation_token = DB.User.select_invitation_token( "invitation_token", "ice_invitation", "engagement_uuid", enguuid, second_user_content['email'], 1) inviterURL = Constants.Default.InviteURL.Login.TEXT + invitation_token Frontend.General.re_open(inviterURL) actualVfNameid = "clickable-" + vfFullName Frontend.User.login(second_user_content['email'], Constants.Default.Password.TEXT, actualVfNameid) Wait.modal_to_dissappear() Frontend.Overview.click_on_vf(user_content) Wait.text_by_id(Constants.Dashboard.Overview.Title.ID, vfFullName)
def search_by_manual_id(manual_id): Enter.text_by_id(Constants.Dashboard.LeftPanel.SearchBox.ID, manual_id, wait_for_page=True) Click.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS, wait_for_page=True) Wait.id(Constants.Dashboard.Overview.Title.ID)
def clear(attr_id_value): try: Wait.id(attr_id_value) session.ice_driver.find_element_by_id(attr_id_value).clear() except Exception: errorMsg = "Failed to clear text box" raise Exception(errorMsg, attr_id_value)
def meta_order_by_id(attr_id_value): try: Wait.id(attr_id_value) return session.ice_driver.find_element_by_id( attr_id_value).get_attribute("meta-order") except Exception: errorMsg = "Failed to get meta order by id:" + attr_id_value raise Exception(errorMsg, attr_id_value)
def go_to_checklist(engagement_id, cl_uuid): try: Click.id(engagement_id) Click.id("checklist-" + cl_uuid) Wait.id("line-item-description") except Exception as e: errorMsg = "Failed to go to checklist page." raise Exception(errorMsg, e)
def open_documentation(title): try: Click.id("documentation", wait_for_page=True) Wait.id("search-doc") Wait.text_by_id(title, title, wait_for_page=True) except Exception as e: errorMsg = "Failed to go to Announcement page." raise Exception(errorMsg, e)
def click_on_export_excel(user_content): Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, user_content['vfName']) engName = user_content['engagement_manual_id'] + ": " + user_content[ 'vfName'] engSearchID = "eng-" + engName Wait.id(engSearchID) # Find the download link and click it Click.id(Constants.Dashboard.Statuses.ExportExcel.ID)
def test_search_bar(self): """ Create user and VF, log in, add VFC, search by EID, VF and VFC """ vfFullName = self.user_content[ 'engagement_manual_id'] + ": " + self.user_content['vfName'] try: Enter.text_by_id( Constants.Dashboard.LeftPanel.SearchBox.ID, self.user_content['vfName']) Wait.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS) Click.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS) Wait.text_by_id( Constants.Dashboard.Overview.Title.ID, vfFullName) except BaseException: errorMsg = "Failed to search by VF name." raise Exception(errorMsg) try: Enter.text_by_id( Constants.Dashboard.LeftPanel.SearchBox.ID, self.user_content['engagement_manual_id']) Enter.text_by_id( Constants.Dashboard.LeftPanel.SearchBox.ID, self.user_content['engagement_manual_id']) Wait.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS) Click.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS) Wait.text_by_id( Constants.Dashboard.Overview.Title.ID, vfFullName) except BaseException: errorMsg = "Failed to search by Engagement Manual ID." raise Exception(errorMsg) Frontend.Overview.click_on_vf(self.user_content) detailedViewID = Constants.Dashboard.DetailedView.ID + vfFullName Wait.text_by_id(detailedViewID, "Detailed View", wait_for_page=True) Click.id(detailedViewID, wait_for_page=True) Click.id( Constants.Dashboard.DetailedView.VFC.Add.ID, wait_for_page=True) vfcName = Helper.rand_string("randomString") extRefID = Helper.rand_string("randomNumber") Enter.text_by_name("name", vfcName) Enter.text_by_name("extRefID", extRefID, wait_for_page=True) Select(session.ice_driver.find_element_by_id( Constants.Dashboard.DetailedView.VFC.Choose_Company.ID)).\ select_by_visible_text(self.user_content['vendor']) Click.id( Constants.Dashboard.DetailedView.VFC.Save_button.ID, wait_for_page=True) try: Enter.text_by_id( Constants.Dashboard.LeftPanel.SearchBox.ID, vfcName, wait_for_page=True) Click.id( "search-" + self.user_content['vfName'], wait_for_page=True) Wait.id("clickable-" + vfFullName, wait_for_page=True) except Exception as e: errorMsg = "Failed to search by VFC name." raise Exception(errorMsg + str(e))
def update_cl_associated_files(engagement_manual_id): Click.id("edit-checklist", True) Wait.text_by_id("modal-header-checklist-15", "Update Checklist") # Select associated files from multi-select drop-down. Click.xpath("//multiselect/div/button") Click.link_text("file2") Click.xpath("//multiselect/div/button") Click.css(Constants.SubmitButton.CSS) Wait.id(engagement_manual_id, True)
def wysiwyg_element_by_id(attr_id_value): try: Wait.id(attr_id_value) return session.ice_driver.find_element_by_css_selector( "#" + attr_id_value + ".wysiwyg-textarea") # If failed - count the failure and add the error to list of errors. except Exception: errorMsg = "Failed to get element by id " + attr_id_value raise Exception(errorMsg, attr_id_value)
def click_on_dashboard_and_validate_statistics(is_negative): # Click.id(Constants.Dashboard.Default.DASHBOARD_ID) Wait.page_has_loaded() if is_negative: session.run_negative( lambda: Wait.id(Constants.Dashboard.Default.STATISTICS), "Negative test failed at Statistics appears") else: Wait.id(Constants.Dashboard.Default.STATISTICS)
def validate_deployment_targets(user_content, users): for user in users: FEGeneral.re_open(Constants.Default.LoginURL.TEXT) logger.debug("Login with user " + user) FEUser.login(user, Constants.Default.Password.TEXT) FEDetailedView.search_vf_and_go_to_detailed_view( user_content['engagement_manual_id'], user_content['vfName']) Wait.id(Constants.Dashboard.DetailedView.DeploymentTarget. AddDeploymentTargetButton.ID)
def test_Validate_SSHkeyNS(self): ''' Insert a valid ssh key in wizard, validate "add ssh key" next step marked as completed. ''' user_content = API.User.create_new_user() activationUrl = DB.User.get_activation_url(user_content['email']) Frontend.General.re_open(activationUrl) Frontend.User.login(user_content['email'], Constants.Default.Password.TEXT) Wait.text_by_id(Constants.Toast.ID, Constants.Dashboard.ActivateMsg.Success.TEXT) Click.id(Constants.Dashboard.Wizard.CloseButton.ID) Wait.modal_to_dissappear() Frontend.User.logout() Frontend.User.login(user_content['email'], Constants.Default.Password.TEXT) Wait.text_by_css(Constants.Dashboard.LeftPanel.Title.CSS, Constants.Dashboard.LeftPanel.Title.TEXT) logger.debug("click_on on + Dashboard") Click.id(Constants.Dashboard.LeftPanel.AddEngagement.ID) # Wizard vfName = Frontend.Wizard.add_vf() Frontend.Wizard.add_vendor_contact() inviteEmail = Helper.rand_invite_email() Frontend.Wizard.invite_team_members(inviteEmail) sshKey = Frontend.Wizard.add_ssh_key() Frontend.User.go_to_account() Wait.id(user_content['email']) actualFullName = Get.value_by_name( Constants.Dashboard.Avatar.Account.FullName.NAME) Helper.internal_assert(user_content['full_name'], actualFullName) actualSSHkey = Get.value_by_name( Constants.Dashboard.Avatar.Account.SSHKey.NAME) Helper.internal_assert(sshKey, actualSSHkey) Click.id(Constants.Dashboard.Statuses.ID) # VALIDATION FOR CONFIRMED BY ENG. LEAD engLeadEmail = DB.User.select_el_email(vfName) engagement_id = DB.General.select_where("engagement_id", "ice_vf", "name", vfName, 1) engagement_manual_id = DB.General.select_where("engagement_manual_id", "ice_engagement", "uuid", engagement_id, 1) myVfName = engagement_manual_id + ": " + vfName actualVfNameid = "clickable-" + myVfName Click.id(actualVfNameid) Click.id("overview-" + myVfName) Click.css("span.engagement_detail_menu_name") Click.xpath("//span[2]/multiselect/div/button") Click.link_text("Completed") elFullName = DB.General.select_where("full_name", "ice_user_profile", "email", engLeadEmail, 1) idNs = elFullName + "_Completed" actualConfirmBy = str(Get.by_id(idNs)) expectedConfirmBy = "System Next Step Completed: " Helper.internal_assert(expectedConfirmBy, actualConfirmBy)
def is_selected_by_id(attr_id_value, wait_for_page=False): try: if wait_for_page: Wait.page_has_loaded() Wait.id(attr_id_value) return session.ice_driver.find_element_by_id( attr_id_value).is_selected() except Exception: errorMsg = "Failed to get if it's selected by id:" + attr_id_value raise Exception(errorMsg, attr_id_value)
def by_id(attr_id_value, wait_for_page=False): try: if wait_for_page: Wait.page_has_loaded() Wait.id(attr_id_value) return session.ice_driver.find_element_by_id(attr_id_value).text # If failed - count the failure and add the error to list of errors. except Exception: errorMsg = "Failed to get text of element " + attr_id_value raise Exception(errorMsg, attr_id_value)
def id(element_id, wait_for_page=False): try: if wait_for_page: Wait.page_has_loaded() Wait.id(element_id) session.ice_driver.find_element_by_id(element_id).click() # If failed - count the failure and add the error to list of errors. except Exception as e: errorMsg = "Failed to click_on on ID " + element_id raise Exception(errorMsg, e)
def is_checkbox_selected_by_id(attr_id_value, wait_for_page=False): try: if wait_for_page: Wait.page_has_loaded() Wait.id(attr_id_value) return Helper.internal_assert_boolean_true_false( session.ice_driver.find_element_by_id( attr_id_value).get_attribute("value"), "on") except Exception: errorMsg = "Failed to get if it's selected by id:" + attr_id_value raise Exception(errorMsg, attr_id_value)
def statuses_search_vf(engagement_manual_id, vf_name): engName = engagement_manual_id + ": " + vf_name # Search by VF name. Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, vf_name, wait_for_page=True) Wait.id("eng-" + engName, wait_for_page=True) Click.id("eng-" + engName, wait_for_page=True) Wait.text_by_id(Constants.Dashboard.Overview.Title.ID, engName, wait_for_page=True)
def update_cl_name_and_associated_files(engagement_manual_id): Click.id("edit-checklist", True) Wait.text_by_id("modal-header-checklist-15", "Update Checklist") newfileName = "file" + Helper.rand_string("randomString") Enter.text_by_xpath("//div[3]/div/div/input", newfileName) updatedFileName = "file2" # Select associated files from multi-select drop-down. Click.xpath("//multiselect/div/button") Click.link_text("file2") Click.css(Constants.SubmitButton.CSS) Wait.id(engagement_manual_id) newFileNames = [newfileName, updatedFileName] return newFileNames
def test_validate_duplicate_invite(self): user_content = [] for _ in range(3): user_content.append( API.VirtualFunction.create_engagement(wait_for_gitlab=False)) Frontend.User.login(user_content[0]['email'], Constants.Default.Password.TEXT) engName = user_content[0][ 'engagement_manual_id'] + ": " + user_content[0]['vfName'] vf_left_nav_id = "clickable-" + engName Click.id(vf_left_nav_id) Frontend.Wizard.invite_team_members_modal(user_content[1]['email']) enguuid = DB.General.select_where( "uuid", "ice_engagement", "engagement_manual_id", user_content[0]['engagement_manual_id'], 1) invitation_token = DB.User.select_invitation_token( "invitation_token", "ice_invitation", "engagement_uuid", enguuid, user_content[1]['email'], 1) inviterURL = Constants.Default.InviteURL.Login.TEXT + invitation_token Frontend.General.re_open(inviterURL) title_id = "title-id-" + engName Frontend.User.login(user_content[1]['email'], Constants.Default.Password.TEXT, title_id) vf_left_nav_id = "clickable-" + engName Click.id(vf_left_nav_id) actualVfName = Get.by_id(vf_left_nav_id) Helper.internal_assert(engName, actualVfName) Wait.text_by_id(Constants.Dashboard.Overview.Title.ID, engName) Frontend.User.logout() Frontend.User.login(user_content[0]['email'], Constants.Default.Password.TEXT) engName = user_content[0][ 'engagement_manual_id'] + ": " + user_content[0]['vfName'] vf_left_nav_id = "clickable-" + engName Click.id(vf_left_nav_id) Click.id(Constants.Dashboard.Overview.TeamMember.ID) Wait.text_by_css( Constants.Dashboard.Wizard.Title.CSS, Constants.Dashboard.Wizard.InviteTeamMembers.Title.TEXT) Enter.text_by_name("email", user_content[1]['email']) Wait.text_by_css( Constants.SubmitButton.CSS, Constants.Dashboard.Wizard.InviteTeamMembers.Button.TEXT) Click.css(Constants.SubmitButton.CSS) Wait.id(Constants.Toast.ID) Helper.internal_assert(Get.by_id(Constants.Toast.ID), "Invite couldn't be created")
def add_next_step_updated(checklistName, newFileName): Click.id(Constants.Dashboard.Checklist.AddNS.ID) Wait.id(Constants.Dashboard.Modal.CLOSE_BUTTON_ID) Wait.text_by_css("span.font_header.ng-binding", "Checklist:") Wait.text_by_css("h2.ng-binding", "Add Next Steps") # First NS Click.id("description") Enter.text_by_id("description", "description of NS") Click.css("div.modal-content") Click.xpath("(//button[@type='button'])[10]") Click.link_text(newFileName) Click.css("div.modal-content") Click.xpath("(//button[@type='button'])[11]") try: Click.xpath("//div[3]/multiselect/div/ul/li/a") except BaseException: Wait.link_text("Homer Simpson") Click.link_text("Homer Simpson") Wait.css("div.modal-content") Click.css("div.modal-content") Wait.xpath("(//button[@type='button'])[12]") count = 0 FEWizard.date_picker_add_ns(count) count = +1 Click.css("span.add-text") Click.xpath("(//div[@id='description'])[2]") Enter.text_by_xpath("(//div[@id='description'])[2]", "description of NS2") Click.css("div.modal-content") Click.xpath("(//button[@type='button'])[14]") Click.xpath("(//button[@type='button'])[22]") Click.xpath("//div[3]/div/div[2]/multiselect/div/ul/li[2]/a") Click.css("div.modal-content") Click.xpath("(//button[@type='button'])[23]") Click.css("div.btn-group.open > ul.dropdown-menu > " + "li.ng-scope > a.ng-binding") Click.link_text("Add Another Next Step") Wait.xpath("(//button[@type='button'])[25]") Click.xpath("(//button[@type='button'])[25]") Wait.xpath("(//button[@type='button'])[24]") FEWizard.date_picker_add_ns(count) Wait.xpath("//div[4]/div/span") Click.xpath("//div[4]/div/span") Wait.id("btn-submit") Wait.text_by_id("btn-submit", "Submit Next Steps") Click.id("btn-submit")
def create_cl_without_files(user_content): FEOverview.click_on_vf(user_content) Click.id("checklist-plus-" + user_content['engagement_uuid']) Wait.id(Constants.Dashboard.Modal.CLOSE_BUTTON_ID) checklistName = "NoAssociatedFiles" + \ Helper.rand_string("randomString") Enter.text_by_name("checkListName", checklistName) Wait.xpath("//select") if settings.DATABASE_TYPE == 'local': Select(session.ice_driver.find_element_by_xpath( "//select")).select_by_visible_text( Constants.Template.Heat.TEXT) else: Click.xpath("//select") Click.xpath("//option[2]") Click.id(Constants.Dashboard.LeftPanel.CreateChecklist.ID) Wait.text_by_id(Constants.Dashboard.Checklist.Name.ID, checklistName)
def invite_and_validate_limit(user_content, vf_left_nav_id): Click.id(Constants.Dashboard.LeftPanel.AddEngagement.ID) FEWizard.add_vf() Click.id(Constants.Dashboard.Wizard.CloseButton.ID, wait_for_page=True) Click.id(vf_left_nav_id) Click.id(Constants.Dashboard.Overview.TeamMember.ID) Wait.text_by_css( Constants.Dashboard.Wizard.Title.CSS, Constants.Dashboard.Wizard.InviteTeamMembers.Title.TEXT) Enter.text_by_name("email", user_content[1]['email']) Wait.text_by_css( Constants.SubmitButton.CSS, Constants.Dashboard.Wizard.InviteTeamMembers.Button.TEXT) Click.css(Constants.SubmitButton.CSS) Wait.id(Constants.Toast.ID) Helper.internal_assert(Get.by_id(Constants.Toast.ID), "Invite couldn't be created")
def text_by_id(attr_id_value, typed_text, wait_for_page=False): # Send keys to element in UI, by ID locator (e.g. type something in # text box). try: if wait_for_page: Wait.page_has_loaded() Wait.id(attr_id_value) session.ice_driver.find_element_by_id(attr_id_value).clear() session.ice_driver.find_element_by_id( attr_id_value).send_keys(typed_text[:-1]) time.sleep(session.wait_until_time_pause) session.ice_driver.find_element_by_id( attr_id_value).send_keys(typed_text[-1:]) # If failed - count the failure and add the error to list of errors. except Exception: errorMsg = "Failed to type " + typed_text + " in text box" raise Exception(errorMsg, attr_id_value)
def remove_deployment_target(user_content): Wait.text_by_id("visible-dts-Lisle (DPA3)", "Lisle (DPA3)", wait_for_page=True) dt_site_id = DBGeneral.select_query( "SELECT uuid FROM public.ice_deployment_target_site where name" + " = 'Lisle (DPA3)'") Click.id("visible-dts-Lisle (DPA3)") Wait.id( Constants.Dashboard.DetailedView.DeploymentTarget.ID_REMOVE_DTS + dt_site_id) Click.id( Constants.Dashboard.DetailedView.DeploymentTarget.ID_REMOVE_DTS + dt_site_id, wait_for_page=True) session.run_negative( lambda: Wait.text_by_id("visible-dts-Lisle (DPA3)", "Lisle (DPA3)", wait_for_page=True), "Negative test failed at wait text Lisle (DPA3)")
def validate_filtering_by_stage(user_content, stage): FEGeneral.re_open(Constants.Default.LoginURL.TEXT) # Validate Scrolling # FEUser.login(user_content['el_email'], Constants.Default.Password.TEXT) FEOverview.click_on_vf(user_content) Click.id(Constants.Dashboard.Statuses.ID, wait_for_page=True) Wait.text_by_id("dashboard-title", "Statuses", wait_for_page=True) Wait.id("search-filter-stage") Select(session.ice_driver.find_element_by_id( "search-filter-stage")).select_by_visible_text(stage) Wait.id(Constants.Dashboard.Statuses.ExportExcel.ID, wait_for_page=True) engLeadID = DBUser.select_user_native_id(user_content['el_email']) # Query for fetching count of rows per stage. countOfEngInStagePerUser = DBUser.select_user_engagements_by_stage( stage, engLeadID) # Calculate number of pages # NUM_OF_RESULTS_PER_PAGES = 8 number_of_pages = countOfEngInStagePerUser // NUM_OF_RESULTS_PER_PAGES logger.debug("Number of pages: " + str(number_of_pages)) if (countOfEngInStagePerUser % NUM_OF_RESULTS_PER_PAGES != 0): number_of_pages += 1 logger.debug("number_of_pages " + str(number_of_pages)) # Scroll # Wait.id("engagements-pagination", wait_for_page=True) element = session.ice_driver.find_element_by_id( "engagements-pagination") element.location_once_scrolled_into_view Click.link_text(str(number_of_pages), wait_for_page=True)
def test_starred_recent_searchbar(self): actualVfName = Get.by_id(self.left_panel_eng_id) Helper.internal_assert(self.eng_title, actualVfName) Click.id(self.left_panel_eng_id) Wait.id("title-id-" + self.eng_title) Helper.internal_assert( self.user_content['engagement_manual_id'] + ":", Get.by_id( "title-id-" + self.eng_title)) Click.id(Constants.Dashboard.Overview.Star.ID, wait_for_page=True) Wait.id("title-id-" + self.eng_title) Click.id(Constants.Dashboard.Overview.Star.ID, wait_for_page=True) Wait.id("title-id-" + self.eng_title, wait_for_page=True) Helper.internal_assert( self.eng_title, Get.by_id(self.left_panel_eng_id)) Enter.text_by_xpath( "//input[@type='text']", self.user_content['engagement_manual_id'], wait_for_page=True) Wait.text_by_css( Constants.Dashboard.LeftPanel.SearchBox.Results.CSS, self.eng_title) Click.css( Constants.Dashboard.LeftPanel.SearchBox.Results.CSS, wait_for_page=True)
def update_ecomp_release(EcompName): count = 0 try: Click.id(Constants.Dashboard.DetailedView.ValidationDetails.PLUS) Wait.text_by_id( Constants.Dashboard.Modal.TITLE_ID, Constants.Dashboard.DetailedView.ValidationDetails.TITLE, wait_for_page=True) Click.id(Constants.Dashboard.DetailedView.ECOMP.Dropdown.ID, wait_for_page=True) Select( session.ice_driver.find_element_by_id( Constants.Dashboard.DetailedView.ECOMP.Dropdown.ID) ).select_by_visible_text(EcompName) Click.id(Constants.Dashboard.DetailedView.ValidationDetails. ECOMPRelease.ID_ECOMP + EcompName, wait_for_page=True) count += 1 Wait.id(Constants.Dashboard.DetailedView.ValidationDetails. ECOMPRelease.ID_ECOMP + Constants.Dashboard.DetailedView. ValidationDetails.ECOMPRelease.UNKNOW, wait_for_page=True) Select( session.ice_driver.find_element_by_id( Constants.Dashboard.DetailedView.ECOMP.Dropdown.ID) ).select_by_visible_text(Constants.Dashboard.DetailedView. ValidationDetails.ECOMPRelease.UNKNOW) Click.id(Constants.Dashboard.DetailedView.ValidationDetails. ECOMPRelease.ID_ECOMP + Constants.Dashboard.DetailedView. ValidationDetails.ECOMPRelease.UNKNOW, wait_for_page=True) count += 1 Click.id(Constants.Dashboard.DetailedView.ValidationDetails.SAVE, wait_for_page=True) Helper.internal_assert(count, 2) # If failed - count the failure and add the error to list of errors. except BaseException: errorMsg = "Failed in update_ecomp_release ." raise Exception(errorMsg)
def validate_filtering_by_stage_with_page_ids(user_content, stage): FEOverview.click_on_vf(user_content) Click.id(Constants.Dashboard.Statuses.ID) # Stage Active Validation # Wait.text_by_id("dashboard-title", "Statuses") Wait.id(Constants.Dashboard.Statuses.FilterDropdown.ID) Select( session.ice_driver.find_element_by_id( Constants.Dashboard.Statuses.FilterDropdown.ID) ).select_by_visible_text("Intake") Wait.page_has_loaded() Select( session.ice_driver.find_element_by_id( Constants.Dashboard.Statuses.FilterDropdown.ID) ).select_by_visible_text(stage) Wait.id(Constants.Dashboard.Statuses.ExportExcel.ID, wait_for_page=True) countIdsActive = 0 engLeadID = DBUser.select_user_native_id(user_content['el_email']) countOfEngInStagePerUser = DBUser.select_user_engagements_by_stage( stage, engLeadID) # Calculate number of pages # NUM_OF_RESULTS_PER_PAGES = 8 number_of_pages = countOfEngInStagePerUser // NUM_OF_RESULTS_PER_PAGES if countOfEngInStagePerUser <= NUM_OF_RESULTS_PER_PAGES: number_of_pages = 1 if number_of_pages == 1: # Count all engagements on current page logger.debug("Number of pages: " + str(number_of_pages)) ids = session.ice_driver.find_elements_by_xpath('//*[@id]') for ii in ids: if "starred-" in ii.get_attribute('id'): # Print ii.tag_name (id name as string). logger.debug(ii.get_attribute('id')) countIdsActive += 1 Wait.id(Constants.Dashboard.Statuses.ExportExcel.ID) if countIdsActive == countOfEngInStagePerUser: logger.debug("result right") else: if countOfEngInStagePerUser % NUM_OF_RESULTS_PER_PAGES != 0: number_of_pages += 1 logger.debug("number_of_pages " + str(number_of_pages)) # Scroll # Wait.id("engagements-pagination") element = session.ice_driver.find_element_by_id( "engagements-pagination") element.location_once_scrolled_into_view if number_of_pages > 1: Click.link_text(str(number_of_pages), wait_for_page=True)
def login(email, password, expected_element=Constants.Dashboard.Statuses.Title.ID, element_type="id"): try: logger.debug("Verifying and Insert Login page elements:") logger.debug("Insert Email " + email) Wait.name(Constants.Login.Email.NAME, wait_for_page=True) Enter.text_by_name(Constants.Login.Email.NAME, email) logger.debug("Insert Password") Enter.text_by_name(Constants.Login.Password.NAME, password) logger.debug("Click Login Button") Click.css(Constants.SubmitButton.CSS) logger.debug("Login Button clicked") if element_type == 'id': Wait.id(expected_element, True) elif element_type == 'css': Wait.css(expected_element, True) # If failed - count the failure and add the error to list of errors. except Exception as e: errorMsg = "Login FAILED: email=%s password=%s" % (email, password) logger.error(errorMsg) raise Exception(errorMsg, e)