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 add_vf(): try: logger.debug("Tab Add Virtual Functions") Wait.text_by_css( Constants.Dashboard.Wizard.Title.CSS, Constants.Dashboard.Wizard.AddVF.Title.TEXT, wait_for_page=True) vfName = "newVF" + Helper.rand_string("randomString") vfVersion = "newVFVersion" + \ Helper.rand_string( "randomNumber") + Helper.rand_string("randomString") Enter.text_by_name("virtualFunction", vfName) Enter.text_by_name("VFversion", vfVersion, wait_for_page=True) FEWizard.date_picker_wizard() Select(session.ice_driver.find_element_by_id( Constants.Dashboard.Wizard.AddVF.AIC_Version.TEXT )).select_by_visible_text("AIC 3.5") Select(session.ice_driver.find_element_by_id( Constants.Dashboard.Wizard.AddVF.ECOMP_Release.TEXT )).select_by_visible_text("Unknown") session.E2Edate = FEWizard.get_lab_entry_date() Click.css(Constants.SubmitButton.CSS, wait_for_page=True) Wait.page_has_loaded() Wait.name_to_dissappear("Add Virtual Function") return vfName # If failed - count the failure and add the error to list of errors. except Exception as e: errorMsg = "Failed to add a Virtual Function via modal window. " +\ "Exception " +\ str(e) raise Exception(errorMsg)
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 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 search_in_left_searchbox_by_param(manual_id, vf_name, param): myVfName = manual_id + ": " + vf_name Enter.text_by_xpath( Constants.Dashboard.LeftPanel.SearchBox.Results.XPATH, param) Wait.text_by_css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS, myVfName) Click.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS)
def edit_template_and_save(): Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_SECTION_ID) Enter.text_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_SECTION_INPUT_ID, "Ros Is My Mentor") FEChecklistTemplate.click_on_save_and_assert_success_msg()
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 add_lineitem_and_check_db(): Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_SECTION_ID) Enter.text_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_SECTION_INPUT_ID, "Ros Is My Mentor") FEChecklistTemplate.click_on_save_and_assert_success_msg() result = DBChecklist.checkChecklistIsUpdated() Helper.internal_not_equal(result, None)
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 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 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 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 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 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_title(title, user_content): FEDashboard.open_documentation(title) Wait.text_by_id(title, title) logger.debug("Search Documentation by title") Enter.text_by_id(Constants.Cms.SearchDocumentation, title, wait_for_page=True) Wait.text_by_id(title, title) Click.id(title, wait_for_page=True) Wait.text_by_id(title, title) logger.debug("Documentation found (searched by title)")
def del_lineitem_and_save(): Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_SECTION_ID, wait_for_page=True) Enter.text_by_id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_SECTION_INPUT_ID, "Ros Is My Mentor", wait_for_page=True) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_SECTION_ID) FEChecklistTemplate.click_on_save_and_assert_success_msg()
def add_vfc(): vfcName = "VFC-" + Helper.rand_string("randomString") Click.id(Constants.Dashboard.DetailedView.VFC.Add.ID) Enter.text_by_name("name", vfcName) session.ice_driver.find_element_by_name("extRefID").click() Enter.text_by_name("extRefID", Helper.rand_string("randomNumber")) Select( session.ice_driver.find_element_by_id( Constants.Dashboard.DetailedView.VFC.Choose_Company.ID) ).select_by_visible_text(ServiceProvider.MainServiceProvider) Click.id(Constants.Dashboard.DetailedView.VFC.Save_button.ID) return vfcName
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 add_line_item_audit_log(): try: log_txt = Helper.rand_string("randomString") Enter.text_by_id("new-audit-log-text", log_txt, wait_for_page=True) Click.id("submit-new-audit-lop-text") Wait.text_by_css( Constants.Dashboard.Checklist.AuditLog.LastLocalAuditLog.CSS, log_txt, wait_for_page=True) return log_txt except Exception as e: errorMsg = "Failed to add audit log to line item." raise Exception(errorMsg, e)
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()
def update_target_lab_entry(): Click.id(Constants.Dashboard.DetailedView.TargetLabEntry.CHANGE, wait_for_page=True) Enter.date_picker('#lab-entry-date', 'vm.targetLabDate', wait_for_page=True) Click.css(Constants.Dashboard.DetailedView.TargetLabEntry.INPUT_CSS, wait_for_page=True) Click.css(Constants.SubmitButton.CSS, wait_for_page=True) actualDate = Get.by_css( Constants.Dashboard.DetailedView.TargetLabEntry.CONTENT_CSS, wait_for_page=True) return str(actualDate)
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_lineitem_and_save(): Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. ADD_LINE_ITEM_BTN, wait_for_page=True) Click.xpath("//li[@id='select-lineitem-btn-0.1']/span[2]") Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN) Enter.text_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_NAME, "xxx") Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN, wait_for_page=True) FEChecklistTemplate.click_on_save_and_assert_success_msg()
def search_in_dashboard(user_content, vfcName, users): engName = user_content['engagement_manual_id'] + ": " + user_content[ 'vfName'] engSearchID = "eng-" + engName for user in users: FEGeneral.re_open(Constants.Default.LoginURL.TEXT) logger.debug("Login with user " + user) FEUser.login(user, Constants.Default.Password.TEXT) logger.debug("Search engagement by engagement_manual_id") Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, user_content['engagement_manual_id']) eng_manual_id = user_content['engagement_manual_id'] + ":" Wait.text_by_id(engSearchID, eng_manual_id) logger.debug("Engagement found (searched by engagement_manual_id)") FEGeneral.smart_refresh() logger.debug("Search engagement by VF name") # Search by VF name. Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, user_content['vfName']) Wait.text_by_id(engSearchID, eng_manual_id) logger.debug("Engagement found (searched by VF name)") FEGeneral.smart_refresh() logger.debug("Search engagement by VFC") # Search by VFC. Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, vfcName) Wait.text_by_id(engSearchID, eng_manual_id) logger.debug("Engagement found (searched by VFC)") FEGeneral.smart_refresh() logger.debug("Negative search: search by random string") # Search by VFC. Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, "RND_STR_" + Helper.rand_string("randomString")) Wait.text_by_id("search-results", "Export to Excel >>")
def reject(rejectMsg=None): try: Click.id(Constants.Dashboard.Checklist.Reject.ID, wait_for_page=True) if rejectMsg: Enter.text_by_name( Constants.Dashboard.Checklist.Reject.Modal.Comment.NAME, rejectMsg, wait_for_page=True) Click.id(Constants.Dashboard.Checklist.Reject.Modal.Button.ID, wait_for_page=True) except Exception as e: errorMsg = "Failed to reject checklist." raise Exception(errorMsg, e)
def test_XSS_script(self): user_content = API.VirtualFunction.create_engagement( wait_for_gitlab=False) validate = API.User.update_account_injec_script(user_content) assertTrue(validate) Frontend.User.login(user_content['email'], Constants.Default.Password.TEXT) Frontend.User.open_account_form() script = "<script>;</script>" Enter.text_by_name("fullname", script, wait_for_page=True) Wait.text_by_css(Constants.SubmitButton.CSS, "Update") Click.css(Constants.SubmitButton.CSS, wait_for_page=True) Wait.text_by_css(Constants.Toast.CSS, "Account was updated successfully!")
def reset_password(): Wait.text_by_css(Constants.UpdatePassword.Title.CSS, Constants.UpdatePassword.Title.TEXT) Wait.text_by_css(Constants.UpdatePassword.SubTitle.CSS, Constants.UpdatePassword.SubTitle.TEXT) Wait.text_by_css(Constants.SubmitButton.CSS, Constants.UpdatePassword.Button.TEXT) Enter.text_by_name(Constants.UpdatePassword.Password.NAME, Constants.Default.Password.NewPass.TEXT) Enter.text_by_name(Constants.UpdatePassword.ConfirmPassword.NAME, Constants.Default.Password.NewPass.TEXT) Click.css(Constants.SubmitButton.CSS) Wait.text_by_id(Constants.Toast.ID, Constants.UpdatePassword.Toast.TEXT)
def edit_description_lineitem_and_save(): desc = Helper.rand_string("randomString") Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_LINE_ITEM_ID) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN) Enter.text_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_NAME, Helper.rand_string("randomString")) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_DESC) editor_element = Get.wysiwyg_element_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate. LINE_ITEM_DESC_TEXT_BOX) editor_element.clear() editor_element.send_keys(desc) Wait.page_has_loaded() actionChains = ActionChains(session.ice_driver) actionChains.double_click(editor_element).perform() Wait.page_has_loaded() Click.xpath(Constants.Dashboard.LeftPanel.EditChecklistTemplate. WYSIWYG_BUTTON_BOLD) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN, wait_for_page=True) isBold = Wait.is_css_exists("b") while not isBold: Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN, wait_for_page=True) actionChains.double_click(editor_element).perform() Click.xpath(Constants.Dashboard.LeftPanel.EditChecklistTemplate. WYSIWYG_BUTTON_BOLD, wait_for_page=True) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN, wait_for_page=True) isBold = Wait.is_css_exists("b") if isBold: FEChecklistTemplate.click_on_save_and_assert_success_msg() FEGeneral.refresh() Click.name(Constants.Dashboard.LeftPanel.EditChecklistTemplate.HEAT, wait_for_page=True) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_LINE_ITEM_ID, wait_for_page=True) Wait.css("b") Wait.text_by_css("b", desc, wait_for_page=True)
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 invite_team_members(email): try: logger.debug("Tab Invite Team Members") Wait.text_by_name( Constants.Dashboard.Wizard.InviteTeamMembers.Title.NAME, Constants.Dashboard.Wizard.InviteTeamMembers.Title.TEXT) Enter.text_by_name("email", email) Wait.text_by_css( Constants.SubmitButton.CSS, Constants.Dashboard.Wizard.InviteTeamMembers.Button.TEXT) Click.css(Constants.SubmitButton.CSS) Wait.name_to_dissappear( Constants.Dashboard.Wizard.InviteTeamMembers.Title.NAME) # If failed - count the failure and add the error to list of errors. except Exception as e: errorMsg = "FAILED in Tab Invite Team Members. Exception = %s" % e raise Exception(errorMsg)