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 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 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 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 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 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 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 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 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 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_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)
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 invite_x_users_from_tm(list_of_invite_emails, countofUser, countOfem, num): Enter.text_by_name("email", list_of_invite_emails[countofUser], wait_for_page=True) for _ in range(num): try: session.run_negative(lambda: Click.css("span.add-icon"), "css appears") break except BaseException: # button exists pass countofUser += 1 # Click.css("span.add-icon") Wait.xpath("//fieldset[" + str(countOfem) + "]/div/input") Enter.text_by_xpath("//fieldset[" + str(countOfem) + "]/div/input", list_of_invite_emails[countofUser]) countOfem += 1 Click.css(Constants.SubmitButton.CSS, wait_for_page=True)
def invite_team_members_modal(email, wait_modal_to_disappear=True): try: Click.id( Constants.Dashboard.Overview.TeamMember.ID, wait_for_page=True) Wait.text_by_css( Constants.Dashboard.Wizard.Title.CSS, 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(".inviteMembers-form button.btn.btn-primary", True) if wait_modal_to_disappear: Wait.modal_to_dissappear() # If failed - count the failure and add the error to list of errors. except Exception as e: errorMsg = "FAILED in PopUp Invite Team Members. Exception=" + \ str(e) raise Exception(errorMsg)
def add_vfcs(name, extRefID): Click.id(Constants.Dashboard.DetailedView.VFC.Add.ID, wait_for_page=True) Wait.text_by_id(Constants.Dashboard.Modal.TITLE_ID, "Add Virtual Function Components (VFCs)") Enter.text_by_name("name", name) Click.name("extRefID", wait_for_page=True) 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("Amdocs") Wait.text_by_css("span.add-text", "Add VFC", wait_for_page=True) Click.css("span.add-text", wait_for_page=True) logger.debug("Add VFC no.2") Enter.text_by_xpath("//div[2]/ng-form/div/input", "djoni2", wait_for_page=True) Enter.text_by_xpath("//div[2]/ng-form/div[2]/input", "loka2") Enter.text_by_xpath("//div[2]/ng-form/div[4]/input", "companyManual2") Click.id(Constants.Dashboard.DetailedView.VFC.Save_button.ID, 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)
def create_checklist(engagement_id, vfName, actualVfName, engagement_manual_id): try: checklistName = Helper.rand_string("randomString") Wait.id("checklist-plus-" + engagement_id, wait_for_page=True) Click.id("checklist-plus-" + engagement_id, wait_for_page=True) Helper.internal_assert("Create Checklist", Get.by_id("modal-header-checklist-15")) # vm.checkListName Enter.text_by_name("checkListName", checklistName, wait_for_page=True) Wait.xpath("//select") Select( session.ice_driver.find_element_by_id( Constants.Template.Subtitle.SelectTemplateTitle.TEXT) ).select_by_visible_text(Constants.Template.Heat.TEXT) Click.id(Constants.Template.Heat.TEXT, wait_for_page=True) # Click.css("option.ng-binding.ng-scope") Helper.internal_assert( "Associate Files", Get.by_id("associated-files-title", wait_for_page=True)) Click.xpath("//multiselect/div/button", wait_for_page=True) Click.link_text("file0", wait_for_page=True) Click.link_text("file1") Wait.text_by_css(Constants.SubmitButton.CSS, "Create Checklist") Click.id(Constants.Dashboard.LeftPanel.CreateChecklist.ID) Wait.modal_to_dissappear() Wait.id(engagement_manual_id) return checklistName # If failed - count the failure and add the error to list of errors. except Exception as e: errorMsg = "Failed to create checklist." + str(e) raise Exception(errorMsg, "create_checklist")
def test_login_negative_required_password(self): ''' Check that password is a required field on login page. ''' user_content = API.User.create_new_user() logger.debug("Verifying and Insert Login page elements:") Enter.text_by_name(Constants.Login.Email.NAME, user_content['email']) Enter.text_by_name(Constants.Login.Password.NAME, "1") Enter.text_by_name(Constants.Login.Password.NAME, "") Wait.text_by_css(Constants.Login.Password.Error.CSS, Constants.Login.Password.Error.TEXT)
def update_account_and_return_changes(): try: Select(session.ice_driver.find_element_by_name( "company")).select_by_visible_text("Nokia") randomName = Helper.rand_string("randomString") Enter.text_by_name("fullname", randomName) phone = "97258" + Helper.rand_string("randomNumber", 6) Enter.text_by_name("phone", phone) password = Constants.Default.Password.NewPass.TEXT Enter.text_by_name("password", password) Enter.text_by_name("confirm_password", password) Wait.text_by_css("button.btn.btn-primary", "Update") Click.css("button.btn.btn-primary") Wait.text_by_id(Constants.Toast.ID, "Account was updated successfully!") Click.id(Constants.Dashboard.Statuses.ID) accountObj = [randomName, phone, password] return accountObj # If failed - count the failure and add the error to list of errors. except BaseException: errorMsg = "Failed in update accaunt ." raise Exception(errorMsg) raise
def add_vendor_contact(): logger.debug("Tab Add Vendor Contact") Wait.text_by_css( Constants.Dashboard.Wizard.Title.CSS, Constants.Dashboard.Wizard.AddVendorContact.Title.TEXT, wait_for_page=True) Select(session.ice_driver.find_element_by_name( "company")).select_by_visible_text("Ericsson") fullname = Helper.rand_string( "randomString") + Helper.rand_string("randomString") Enter.text_by_name("fullname", fullname) email = Helper.rand_string("randomString") + "@ericson.com" Enter.text_by_name("email", email) phone = "201" + Helper.rand_string("randomNumber", 6) Enter.text_by_name("phone", phone) Click.css(Constants.SubmitButton.CSS, wait_for_page=True) Wait.name_to_dissappear("Add Vendor Contact", wait_for_page=True) vendor = {"company": "Ericsson", "full_name": fullname, "email": email, "phone": phone} return vendor
def add_service_provider_internal(): logger.debug( "Tab Add " + ServiceProvider.MainServiceProvider + " Sponsor") Wait.text_by_css( Constants.Dashboard.Wizard.Title.CSS, "Add " + ServiceProvider.MainServiceProvider + " Sponsor") fullname = Helper.rand_string( "randomString") + Helper.rand_string("randomString") Enter.text_by_name("fullname", fullname) email = Helper.rand_string( "randomString") + "@" + ServiceProvider.email Enter.text_by_name("email", email) phone = "201" + Helper.rand_string("randomNumber", 6) logger.debug(phone) Enter.text_by_name("phone", phone) Click.css(Constants.SubmitButton.CSS) Wait.name_to_dissappear("Add AT&T Sponsor") sponsor = {"company": ServiceProvider.MainServiceProvider, "full_name": fullname, "email": email, "phone": phone} return sponsor
def form_enter_name(name): Enter.text_by_name(Constants.Signup.FullName.NAME, name)
def invite_single_user_to_team(email): Enter.text_by_name("email", email, wait_for_page=True) Click.css(Constants.SubmitButton.CSS, wait_for_page=True)
def form_enter_email(email): Enter.text_by_name(Constants.Signup.Email.NAME, email)
def form_enter_phone(phone): Enter.text_by_name(Constants.Signup.Phone.NAME, phone)
def form_enter_password(password): Enter.text_by_name(Constants.Signup.Password.NAME, password)