def test_create_2_new_users(self): ''' Login and activate new user, than reopen browser and loging with new other user - check wizard appears for both Frontend.User. ''' # First APIUser user_content = API.User.create_new_user() logger.debug(user_content['email']) activationUrl = DB.User.get_activation_url(user_content['email']) logger.debug(activationUrl) 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() # Second APIUser user_content = API.User.create_new_user() logger.debug(user_content['email']) activationUrl2 = DB.User.get_activation_url(user_content['email']) logger.debug(activationUrl2) Frontend.General.re_open_not_clean_cache(activationUrl2) 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() Click.id(Constants.Dashboard.Avatar.ID)
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 click_on_update_ecomp_release(): Click.id(Constants.Dashboard.DetailedView.ValidationDetails.PLUS, wait_for_page=True) Wait.text_by_id( Constants.Dashboard.Modal.TITLE_ID, Constants.Dashboard.DetailedView.ValidationDetails.TITLE, wait_for_page=True)
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 add_ssh_key(is_negative=False): logger.debug("About to add an SSH Key in modal window") try: # Add SSH Key from modal window and return key value. Wait.text_by_name(Constants.Dashboard.Wizard.AddSSHKey.Title.NAME, Constants.Dashboard.Wizard.AddSSHKey.Title.TEXT) # Generate an SSH Public Key. sshKey = Helper.generate_sshpub_key() if is_negative: sshKey = sshKey[8:] Enter.text_by_name("key", sshKey) # Check that the submit button exists. Wait.text_by_css( Constants.SubmitButton.CSS, Constants.Dashboard.Wizard.AddSSHKey.Title.TEXT) Click.css(Constants.SubmitButton.CSS) # Click on submit button. if is_negative: Wait.text_by_id( Constants.Toast.ID, Constants.Dashboard.Avatar.Account .SSHKey.UpdateFailed.TEXT) else: Wait.name_to_dissappear( Constants.Dashboard.Wizard.AddSSHKey.Title.NAME) logger.debug("SSH Key added via modal window.") return sshKey # If failed - count the failure and add the error to list of errors. except Exception as e: errorMsg = "Failed to add an SSH Key in " +\ "the modal window. Exception=" + \ str(e) raise Exception(errorMsg)
def open_validation_details(): Click.id(Constants.Dashboard.DetailedView.ValidationDetails.PLUS, wait_for_page=True) Wait.text_by_id( Constants.Dashboard.Modal.TITLE_ID, Constants.Dashboard.DetailedView.ValidationDetails.TITLE, wait_for_page=True)
def remove_vfc(user_content): vf_id = DBGeneral.select_where("uuid", "ice_vf", "name", user_content['vfName'], 1) djoni_uuid = None counter = 0 while not djoni_uuid and counter <= Constants.DBConstants.\ RETRIES_NUMBER: time.sleep(session.wait_until_time_pause_long) djoni_uuid = DBGeneral.select_where_and("uuid", "ice_vfc", "vf_id", vf_id, "name", "djoni", 1) logger.debug("Checklist state not changed yet (%s of %s)" % (counter, Constants.DBConstants.RETRIES_NUMBER)) counter += 1 logger.debug("VFC_UUID was successfully selecteded : " + djoni_uuid + ", and was verified over the DB") Wait.text_by_id(Constants.Dashboard.DetailedView.VFC.ID + "djoni", "djoni (loka)", wait_for_page=True) Wait.text_by_id(Constants.Dashboard.DetailedView.VFC.ID + "djoni2", "djoni2 (loka2)", wait_for_page=True) Click.id(Constants.Dashboard.DetailedView.VFC.ID + "djoni", wait_for_page=True) Click.id(Constants.Dashboard.DetailedView.VFC.Remove.ID + djoni_uuid, wait_for_page=True)
def go_to_user_profile_settings(): FEUser.go_to_account() Click.id(Constants.Dashboard.Avatar.Account.UserProfileSettings.ID, wait_for_page=True) Wait.text_by_id( Constants.Dashboard.Avatar.Account.UserProfileSettings.TitleID, Constants.Dashboard.Avatar.Account.UserProfileSettings.TitleText, wait_for_page=True)
def check_select_deselect_all_files(): Click.id(Constants.Dashboard.Overview.NextSteps.Add.AssociatedFiles.ID) Click.link_text(Constants.Dashboard.Overview.NextSteps.Add. AssociatedFiles.SELECT_ALL_FILES_NAME) Wait.text_by_id( Constants.Dashboard.Overview.NextSteps.Add.AssociatedFiles.ID, Constants.Dashboard.Overview.NextSteps.Add.AssociatedFiles. ALL_FILES_SELECTED)
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 search_by_vfname_for_not_local(user_content): vfFullName = user_content[ 'engagement_manual_id'] + ": " + user_content['vfName'] if settings.DATABASE_TYPE != 'local': Enter.text_by_id(Constants.Dashboard.LeftPanel.SearchBox.ID, user_content['vfName']) Click.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS) Wait.text_by_id(Constants.Dashboard.Overview.Title.ID, vfFullName)
def test_login_negative(self): ''' Negative: Type wrong password in login page. ''' user_content = API.User.create_new_user(activate=True) Frontend.User.login(user_content['email'], Helper.rand_string("randomString"), Constants.Toast.ID) Wait.text_by_id(Constants.Toast.ID, Constants.Login.Toast.TEXT) logger.debug( "Message Error(APIUser or Password does not match) Displayed")
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 test_login_negative_email_valid(self): ''' Negative: Type wrong password in login page. ''' user_content = API.User.create_new_user(activate=True) Frontend.User.login(user_content['email'] + "s", Constants.Default.Password.TEXT, Constants.Toast.ID) Wait.text_by_id(Constants.Toast.ID, Constants.Login.Toast.TEXT) logger.debug( "Message Error(APIUser or Password does not match) Displayed")
def validate_grandchild_page(parent_title, child_title, grand_child_title, description): Click.id(Constants.Cms.Documentation) Click.id(parent_title) Click.id(child_title) Click.id(grand_child_title) Wait.text_by_id("center-" + grand_child_title, grand_child_title) page_id = DBCMS.get_last_inserted_page_id() Wait.text_by_id(page_id, description)
def test_entering_engagement_from_dashboard(self): Wait.text_by_id(self.left_panel_eng_id, self.eng_title) DB.VirtualFunction.remove_engagement_from_recent( self.user_content['vf_uuid']) Frontend.General.refresh() Frontend.Dashboard.statuses_search_vf( self.user_content['engagement_manual_id'], self.user_content['vfName']) Wait.text_by_id(self.left_panel_eng_id, self.eng_title)
def test_login_positive(self): ''' Create new user login. ''' user_content = API.User.create_new_user() Frontend.User.login(user_content['email'], Constants.Default.Password.TEXT, Constants.Toast.ID) logger.debug("Resend Activation Email Page Opened ") Wait.text_by_id(Constants.Toast.ID, Constants.ActivateAccount.Toast.TEXT)
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 add_feedback(): Wait.css("textarea[name=\"description\"]", wait_for_page=True) description = Helper.rand_string("randomString") Enter.text_by_css("textarea[name=\"description\"]", description) Click.id(Constants.Dashboard.Feedback.FeedbackModal.SAVE_BTN_ID, wait_for_page=True) Wait.text_by_id(Constants.Toast.ID, "Feedback was sent successfully.", wait_for_page=True) return description
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 search_by_vf(user_content): engName = user_content['engagement_manual_id'] + ": " + user_content[ 'vfName'] engSearchID = "eng-" + engName FEGeneral.re_open_not_clean_cache(Constants.Default.DashbaordURL.TEXT) logger.debug("Search engagement by engagement_manual_id") Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, user_content['engagement_manual_id'], wait_for_page=True) eng_manual_id = user_content['engagement_manual_id'] + ":" Wait.text_by_id(engSearchID, eng_manual_id)
def search_documentation_content(title, content): FEDashboard.open_documentation(title) Wait.text_by_id(title, title) logger.debug("Search Documentation by content") Enter.text_by_id(Constants.Cms.SearchDocumentation, content, wait_for_page=True) Wait.text_by_id(title, title) Click.id(title, wait_for_page=True) Wait.text_by_css(Constants.Cms.DocumentationPageContent, content) logger.debug("Documentation found (searched by content)")
def click_on_save_and_assert_success_msg(): Click.id( Constants.Dashboard.LeftPanel.EditChecklistTemplate.SAVE_BTN_ID, wait_for_page=True) Click.id( Constants.Dashboard.LeftPanel.EditChecklistTemplate.APPROVE_BTN_ID, wait_for_page=True) Wait.text_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate.SUCCESS_ID, Constants.Dashboard.LeftPanel.EditChecklistTemplate. SUCCESS_SAVE_MSG)
def click_on_notifications(): try: Click.link_text(Constants.Dashboard.Avatar.Notifications.LINK_TEXT, wait_for_page=True) Wait.text_by_id( Constants.Dashboard.Avatar.Notifications.Title.ID, Constants.Dashboard.Avatar.Notifications.Title.TEXT, wait_for_page=True) except Exception as e: errorMsg = "Failed to click_on on Admin." raise Exception(errorMsg, e)
def send_reset_password(email): FEGeneral.go_to_reset_password_from_login() Wait.text_by_css(Constants.ResetPassword.Title.CSS, Constants.ResetPassword.Title.TEXT) Enter.text_by_name(Constants.ResetPassword.Email.NAME, email) Wait.text_by_css(Constants.SubmitButton.CSS, Constants.ResetPassword.Button.TEXT) Click.css(Constants.SubmitButton.CSS) Wait.text_by_id(Constants.Toast.ID, Constants.ResetPassword.Toast.Success.TEXT) logger.debug(Constants.ResetPassword.Toast.Success.TEXT)
def get_jenkins_log(): Click.id(Constants.Dashboard.Checklist.JenkinsLog.ID, True) Wait.text_by_id( Constants.Dashboard.Checklist.JenkinsLog.Modal.Title.ID, Constants.Dashboard.Checklist.JenkinsLog.Modal.Title.TEXT, True) log = Get.by_id(Constants.Dashboard.Checklist.JenkinsLog.Modal.Body.ID, True) Helper.assertTrue( Constants.Dashboard.Checklist.JenkinsLog.Modal.Body.TEXT_SAMPLE in log, "Jenkins log could not be viewed.") Click.id(Constants.Dashboard.Modal.CLOSE_BUTTON_ID) return log
def set_ssh_key_from_account(key, is_negative=False): FEUser.go_to_account() Enter.text_by_name(Constants.Dashboard.Avatar.Account.SSHKey.NAME, key) Click.css(Constants.SubmitButton.CSS) if is_negative: Wait.text_by_id( Constants.Toast.ID, Constants.Dashboard.Avatar.Account.SSHKey.UpdateFailed.TEXT) else: Wait.text_by_id( Constants.Toast.ID, Constants.Dashboard.Avatar.Account.Update.Success.TEXT)
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 add_nsteps(checklistUuid, actualVfNameid, myVfName, checklistName, newFileNames): Click.id(actualVfNameid, wait_for_page=True) checklistUuid = DBChecklist.select_where_cl_not_archive( "uuid", "ice_checklist", "name", newFileNames[0], 1) Click.id("checklist-" + checklistUuid, wait_for_page=True) Wait.text_by_id(Constants.Dashboard.Checklist.Name.ID, newFileNames[0]) FEChecklist.add_next_step_updated(checklistName, newFileNames[1]) # vALIDATE SCROLLING actualVfNameid = "clickable-" + myVfName actualVfName = Get.by_id(actualVfNameid, wait_for_page=True) if actualVfName != '': Helper.internal_assert(myVfName, actualVfName)
def reject_checklist(newObj, checklistName): Click.xpath("//button[2]") vfName = newObj[0] engLeadFullName = DBUser.get_el_name(vfName) Enter.text_by_name( Constants.Dashboard.Checklist.Reject.Modal.Comment.NAME, "Reject state By :" + engLeadFullName) Helper.internal_assert("Checklist: " + checklistName, Get.by_css("span.state-title.ng-binding")) Wait.text_by_id(Constants.Dashboard.Checklist.Reject.Modal.Button.ID, Constants.Dashboard.Checklist.Reject.Modal.Button.TEXT) Click.id(Constants.Dashboard.Checklist.Reject.Modal.Button.ID) Wait.modal_to_dissappear()