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 validate_multi_eng(user_content, checklist_content, newEL_content, actualVfNameid): query = "UPDATE ice_user_profile SET role_id=2 WHERE email = '" + \ str(newEL_content['email']) + "';" DBGeneral.update_by_query(query) FEWizard.invite_team_members_modal(newEL_content['email']) # Fetch one AT&T user ID. enguuid = DBGeneral.select_where("uuid", "ice_engagement", "engagement_manual_id", user_content['engagement_manual_id'], 1) invitation_token = DBUser.select_invitation_token( "invitation_token", "ice_invitation", "engagement_uuid", enguuid, newEL_content['email'], 1) URL = Constants.Default.InviteURL.Login.TEXT + invitation_token FEGeneral.re_open(URL) FEUser.login(newEL_content['email'], Constants.Default.Password.TEXT, expected_element=actualVfNameid) Click.id(actualVfNameid, wait_for_page=True) count = None try: session.ice_driver.find_element_by_id("checklist-" + checklist_content['uuid']) count += 1 except BaseException: logger.debug("check list not visible for EL invited : " + str(newEL_content['email'])) assertTrue(count is None) query = "UPDATE ice_user_profile SET role_id=1 WHERE email = '" + \ str(newEL_content['email']) + "';" DBGeneral.update_by_query(query)
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 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 add_remove_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']) FEDetailedView.add_deployment_target(user_content) FEDetailedView.remove_deployment_target(user_content)
def test_ns_choose_all_vf_gitlab_repo_files_via_select_all(self): self.user_content['session_token'] = "token " + \ API.User.login_user(self.user_content['el_email']) API.GitLab.git_clone_push(self.user_content) API.Checklist.create_checklist(self.user_content) FEUser.login(self.user_content['el_email'], Constants.Default.Password.TEXT) FEOverview.click_on_vf(self.user_content) Frontend.Checklist.get_to_create_new_ns_modal_via_overview() FENextStep.check_select_deselect_all_files()
def create_x_vfs(user_content, engName, x): vflist = [] FEUser.login(user_content['email'], Constants.Default.Password.TEXT) for _ in range(x): vf_left_nav_id = "clickable-" + engName Click.id(vf_left_nav_id) Click.id(Constants.Dashboard.LeftPanel.AddEngagement.ID) vfName = FEWizard.add_vf() vflist.append(vfName) Click.id(Constants.Dashboard.Wizard.CloseButton.ID, wait_for_page=True) return vflist
def create_new_checklist(newObj): try: newObjWithChecklist = None vfName = newObj[0] uuid = newObj[1] inviteEmail = newObj[2] # Fetch one AT&T user ID. vfuuid = DBGeneral.select_where("uuid", "ice_vf", "name", vfName, 1) engagement_id = DBVirtualFunction.select_eng_uuid(vfName) engLeadEmail = DBUser.select_el_email(vfName) logger.debug("EL email: " + engLeadEmail) engagement_manual_id = DBGeneral.select_where( "engagement_manual_id", "ice_engagement", "uuid", engagement_id, 1) # Click on all default next steps myVfName = engagement_manual_id + ": " + vfName actualVfNameid = "clickable-" + myVfName actualVfName = Get.by_id(actualVfNameid) Helper.internal_assert(myVfName, actualVfName) # NEXT STEP ID Click.id(actualVfNameid, wait_for_page=True) FEOverview.complete_defaults_nextsteps(engagement_id) inviterURL = Constants.Default.InviteURL.Signup.TEXT + \ vfuuid + "&inviter_uuid=" + uuid + "&email=" + inviteEmail # time.sleep(2) FEGeneral.re_open(inviterURL) FEGeneral.form_validate_email(inviteEmail) # Login with EL role FEGeneral.re_open(Constants.Default.LoginURL.TEXT) FEUser.login(engLeadEmail, Constants.Default.Password.TEXT) Wait.id(Constants.Dashboard.Statuses.Title.ID) Wait.id(engagement_manual_id) # cheklist # VALIDATE SCROLLING actualVfName = Get.by_id(actualVfNameid) myVfName = engagement_manual_id + ": " + vfName # Wait.id(actualVfNameid) Wait.id(engagement_manual_id, wait_for_page=True) Click.id(actualVfNameid, wait_for_page=True) # Create new checklist checklistName = FEChecklist.create_checklist( engagement_id, vfName, actualVfName, engagement_manual_id) checklistUuid = DBGeneral.select_where("uuid", "ice_checklist", "name", checklistName, 1) newObjWithChecklist = [ checklistUuid, engLeadEmail, engagement_manual_id, actualVfNameid, myVfName, checklistName ] return newObjWithChecklist # 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_new_checklist")
def validate_negative_role_for_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']) session.run_negative( lambda: Click.id(Constants.Dashboard.DetailedView. DeploymentTarget.AddDeploymentTargetButton.ID ), "Negative test failed at click_on_ deployment-targets " + "with user %s" % user)
def validate_expired_post_Announcement(email, title, description): title2 = Constants.Toast.TEXT + title + "." Wait.text_by_id(Constants.Toast.CMS_ID, title2, True) FEDashboard.open_announcement() Wait.text_by_id(Constants.Cms.Toast_title_id, title) Wait.text_by_id(Constants.Cms.Toast_description, description) DBCMS.update_X_days_back_post(title, xdays=3) Click.id(Constants.Cms.Test_addDT_close_modal_button) FEUser.logout() FEUser.login(email, Constants.Default.Password.TEXT) session.run_negative( lambda: Wait.text_by_id(Constants.Toast.CMS_ID, title2), "Announcement toast not disappear after 2 days %s" % title)
def announcement_validate_toast(title, description, user_content): Wait.text_by_id(Constants.Toast.CMS_ID, title + ".") FEDashboard.open_announcement() Wait.text_by_id(Constants.Cms.Toast_title_id, title) Wait.text_by_id(Constants.Cms.Toast_description, description) Click.id(Constants.Cms.Test_addDT_close_modal_button) Click.css("button.close") FEUser.logout() FEUser.login(user_content['email'], Constants.Default.Password.TEXT) # Validate Announcement displayed in News & Announcements sections session.run_negative( lambda: FEDashboard.open_announcement(), "Announcement toast disappear after 2 days %s" % title) Wait.text_by_id(title, title) Wait.text_by_id(description, description)
def validate_5_last_announcement_displayed(listOfTitleAnDescriptions, user_content, last_title): last_description = listOfTitleAnDescriptions[ len(listOfTitleAnDescriptions) - 1][1] Wait.text_by_id(Constants.Toast.CMS_ID, last_title + ".") FEDashboard.open_announcement() Wait.text_by_id(Constants.Cms.Toast_title_id, last_title) Wait.text_by_id(Constants.Cms.Toast_description, last_description) DBCMS.update_X_days_back_post(last_title, xdays=3) Click.id(Constants.Cms.Test_addDT_close_modal_button) FEUser.logout() # Validate Announcement TOAST not displayed FEUser.login(user_content['email'], Constants.Default.Password.TEXT) session.run_negative( lambda: Wait.text_by_id(Constants.Cms.Toast_title_id, last_title), "Last Announcement displayed in News & Announcements sections %s" % last_title)
def validations_for_user2(user_content, inviteEmail, vflist): # Fetch one AT&T user ID. engagement_id = DBGeneral.select_where("engagement_id", "ice_vf", "name", vflist[0], 1) engagement_manual_id = DBGeneral.select_where("engagement_manual_id", "ice_engagement", "uuid", engagement_id, 1) engLeadEmail = DBUser.select_el_email(vflist[0]) user_content['engagement_uuid'] = engagement_id user_content['el_email'] = engLeadEmail uuid = DBGeneral.select_where_email("uuid", "ice_user_profile", user_content['email']) sponsor = [ ServiceProvider.MainServiceProvider, 'aaaaaa', inviteEmail, '3058000000' ] invitation_token = DBUser.select_invitation_token( "invitation_token", "ice_invitation", "engagement_uuid", engagement_id, inviteEmail, 1) signUpURLforContact = DBUser.get_contact_signup_url( invitation_token, uuid, sponsor[2], sponsor[1], sponsor[3], sponsor[0]) APIUser.signup_invited_user(sponsor[0], inviteEmail, invitation_token, signUpURLforContact, user_content, True, wait_for_gitlab=False) activationUrl2 = DBUser.get_activation_url(sponsor[2]) FEGeneral.re_open(activationUrl2) # Login with 2nd user # engName = engagement_manual_id + ": " + vflist[0] title_id = "clickable-" + engName FEUser.login(inviteEmail, Constants.Default.Password.TEXT, title_id) for vfName in vflist: # Fetch one AT&T user ID. engagement_id = DBGeneral.select_where("engagement_id", "ice_vf", "name", vfName, 1) engagement_manual_id = DBGeneral.select_where( "engagement_manual_id", "ice_engagement", "uuid", engagement_id, 1) engName = engagement_manual_id + ": " + vfName vf_left_nav_id = "clickable-" + engName Click.id(vf_left_nav_id, wait_for_page=True)
class Frontend: User = FEUser() Invite = FEInvite() Checklist = FEChecklist() Dashboard = FEDashboard() DetailedView = FEDetailedView() General = FEGeneral() Overview = FEOverview() Wizard = FEWizard() Cms = FECms() ChecklistTemplate = FEChecklistTemplate()
def check_cl_after_lineitem_added(): template_name = Constants.Dashboard.LeftPanel.\ EditChecklistTemplate.HEAT user_content = APIVirtualFunction.create_engagement() FEUser.login(Constants.Users.Admin.EMAIL, Constants.Default.Password.TEXT) vfName = user_content['vfName'] engagement_id = DBChecklist.fetchEngByVfName(vfName) engLeadEmail = DBUser.select_el_email(vfName) engagement_manual_id = DBChecklist.fetchEngManIdByEngUuid( engagement_id) FEOverview.click_on_vf(user_content) FEGeneral.re_open(Constants.Default.LoginURL.TEXT) FEUser.login(engLeadEmail, Constants.Default.Password.TEXT, engagement_manual_id) Click.id( Constants.Dashboard.LeftPanel.EditChecklistTemplate.DASHBOARD_ID) Enter.text_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate.SEARCH_ENG_ID, vfName) Click.id("test_" + vfName) checklistName = FEChecklist.create_checklist(engagement_id, vfName, None, engagement_manual_id) FEUser.go_to_admin() result = DBChecklist.fetchChecklistByName(checklistName) FEUser.go_to_admin() FEChecklistTemplate.click_on_template_name_on_navigation( Constants.Dashboard.LeftPanel.EditChecklistTemplate.HEAT, template_name) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN) Enter.text_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_NAME, "test_lineitem_added_and_audit_log_on_dupl_cl-NAME") Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN) FEChecklistTemplate.click_on_save_and_assert_success_msg() Click.id( Constants.Dashboard.LeftPanel.EditChecklistTemplate.DASHBOARD_ID) Enter.text_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate.SEARCH_ENG_ID, vfName) Click.id("test_" + vfName) Click.id("checklist-" + str(result)) Helper.internal_assert( "1. automation", session.ice_driver.find_element_by_xpath("//li[@id='']").text)
def invite_users(user_content): engName = user_content[0][ 'engagement_manual_id'] + ": " + user_content[0]['vfName'] vf_left_nav_id = "clickable-" + engName Click.id(vf_left_nav_id) FEWizard.invite_team_members_modal(user_content[1]['email']) # self.sleep(1) # TODO need to wait until modal window is closed. invitation_token = DBUser.select_invitation_token( "invitation_token", "ice_invitation", "engagement_uuid", user_content[0]['engagement_uuid'], user_content[1]['email'], 1) inviterURL = Constants.Default.InviteURL.Login.TEXT + invitation_token FEGeneral.re_open(inviterURL) # Login with 2nd user # title_id = "title-id-" + engName FEUser.login(user_content[1]['email'], Constants.Default.Password.TEXT, title_id) 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) FEUser.logout() return vf_left_nav_id
def frontend_login(email, password): """login: Originally can be found under FEUser class.""" from services.frontend.fe_user import FEUser return FEUser.login(email, password)
def basic_admin_navigation(): FEUser.login(Constants.Users.Admin.EMAIL, Constants.Default.Password.TEXT) FEUser.go_to_admin()