def testProgramAuditDocumentationRequest(self):
        self.testname="testProgramAuditDocumentationRequest"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers()
        do.setUtils(util)
        do.login()

        #
        # Read audit_setup_data to retrieve program name and the IDs of the 3 objectives
        #
        objectiveID={}
        f=open("audit_setup_data","r")
        program_name=f.readline().strip("\n")

        do.navigateToObjectWithSearch(program_name,"Program")
        util.max_screen()
        
        # 2.  Choose Audit from Object page nav to bring up the Audit widget
        do.navigateToAuditSectionViaInnerNavSection("Audit")
        newly_created_audit = element.audit_area_created_audit.replace("AUDIT_TITLE", "2014: program - Audit")
       
        print newly_created_audit
        util.waitForElementToBePresent(newly_created_audit)
        self.assertTrue(util.isElementPresent(newly_created_audit), "do not see the newly created audit " +"2014: program - Audit" )
        
        # 6. Click on it to open the 2nd tier info.  confirm there are 3 requests in the PBC Requests section. 
        newly_created_audit_open_link  = element.audit_area_created_audit_open_link.replace("AUDIT_TITLE", "2014: program - Audit")
        print newly_created_audit_open_link
        util.waitForElementToBePresent(newly_created_audit_open_link)
        self.assertTrue(util.isElementPresent(newly_created_audit_open_link), "do not see the newly created audit open link "  )
        util.clickOn(newly_created_audit_open_link)
        #util.switch_to_active_element()

        for objective_title in grcobject.objective_title:
            objective_title_element = element.audit_pbc_request.replace("TITLE", objective_title)
            print objective_title_element
            util.waitForElementToBePresent(objective_title_element)
            self.assertTrue(util.isElementPresent(objective_title_element), "do not see the pbc request " + objective_title_element )
        
        util.switch_to_active_element()
        util.get_a_screen_shot("test_screenshot.png")
        
        do.expandCollapseRequest(grcobject.objective_title[0])
        #.    Assign that Response to another team member ([email protected] is fine)
        response_email_inputfield = element.audit_pbc_request_expanded_content_response_email_inputfield.replace("TITLE",grcobject.objective_title[0] )
        print "response_email_inputfield " + response_email_inputfield
        util.waitForElementToBePresent(response_email_inputfield)
        self.assertTrue(util.isElementPresent(response_email_inputfield), "do not see the firts response owner email textfield presented")
        util.inputTextIntoField("*****@*****.**", response_email_inputfield)
        
        #Click on the response header to open the response
        open_response_link = element.audit_pbc_request_response_expand_collapse_link.replace("TITLE",grcobject.objective_title[0] )
        util.waitForElementToBePresent(open_response_link)
        self.assertTrue(util.isElementPresent(open_response_link), "do not see the open close button for the response")
        util.clickOn(open_response_link)
        
        #click +Object to open Map Object Selector. 
        add_object_link = element.audit_pbc_request_response_add_object_link.replace("TITLE",grcobject.objective_title[0] )
        util.waitForElementToBePresent(add_object_link)
        self.assertTrue(util.isElementPresent(add_object_link), "do not see the open close button for the response")
        util.clickOn(add_object_link)
        
        #Change top filter to Org Group. 
        util.waitForElementToBePresent(element.mapping_modal_window)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window), "do not see the modal window")
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown), "do not see the modal window")
        util.selectFromDropdownByValue(element.mapping_modal_top_filter_selector_dropdown, "OrgGroup")
        
        #Choose Reciprocity Dev Team and hit Map button. (use search to find this if easier to implement)
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option), "do not see the open close button for the response")
        util.clickOn(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        util.waitForElementToBePresent(element.mapping_modal_window_map_button)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window_map_button), "no Map button")
        util.clickOn(element.mapping_modal_window_map_button)
        util.waitForElementNotToBePresent(element.mapping_modal_window)
        
         #Confirm Reciprocity Dev Team is mapped to the Response and appears in the area provided
        util.waitForElementToBePresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team), "no Mapped org group button")
        
        #Click +Upload Evidence in the Evidence area to open the file picker
        upload_evidence_link = element.audit_pbc_request_response_upload_evidence_link.replace("TITLE",grcobject.objective_title[0] )
        util.waitForElementToBePresent(upload_evidence_link)
        self.assertTrue(util.isElementPresent(upload_evidence_link), "no Upload Evidence link")
        util.clickOn(upload_evidence_link)
        util.waitForElementToBePresent('//iFrame[@class="picker-frame picker-dialog-frame"]')
        #self.assertTrue(util.isElementPresent('//iFrame[@class="picker-frame picker-dialog-frame"]'), "no Upload window")
        url=util.getAnyAttribute('//iFrame[@class="picker-frame picker-dialog-frame"]', "src")
        print url
        util.switchToNewUrl(url)
        file_is = os.getcwd() + "/test_screenshot.png"
        util.uploadItem(file_is, element.select_file_button)
        util.waitForElementToBeVisible(element.upload_file_button)
        util.find_element_by_xpath(element.upload_file_button).click() 
        time.sleep(10) # wait for uploading the file
        util.backBrowser()
        util.refreshPage()
        #waiting to audit to appear back
        newly_created_audit = element.audit_area_created_audit.replace("AUDIT_TITLE", "2014: program - Audit")
        #newly_created_audit = element.audit_area_created_audit.replace("AUDIT_TITLE", new_audit_title)
        print newly_created_audit
        util.waitForElementToBePresent(newly_created_audit)
        self.assertTrue(util.isElementPresent(newly_created_audit), "do not see the newly created audit 2014: program - Audit")
         
        newly_created_audit_open_link  = element.audit_area_created_audit_open_link.replace("AUDIT_TITLE", "2014: program - Audit") 
        #newly_created_audit_open_link  = element.audit_area_created_audit_open_link.replace("AUDIT_TITLE", new_audit_title)
        print newly_created_audit_open_link
        util.waitForElementToBePresent(newly_created_audit_open_link)
        self.assertTrue(util.isElementPresent(newly_created_audit_open_link), "do not see the newly created audit open link "  )
        util.clickOn(newly_created_audit_open_link)
        util.switch_to_active_element()
        #expand objetiive 1 to verify the uploaded file
        do.expandCollapseRequest(grcobject.objective_title[0])
        evidence_folder_link = element.audit_pb_request_response_evidence_folder_link.replace("TITLE",grcobject.objective_title[0] )
        util.waitForElementToBePresent(evidence_folder_link)
        self.assertTrue(util.isElementPresent(evidence_folder_link), "do not see the evidene folder link "  )
        do.expandCollapseRequest(grcobject.objective_title[0])
Ejemplo n.º 2
0
    def testProgramAuditSetup(self):
        self.testname="TestProgramAuditSetup"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers()
        do.setUtils(util)
        do.login()
        objectiveID = {}
        
        # 1: Create New Program 
        #program_name = "The Program for Auto Test of Audit"  
        #temporary to use one program with unique name
        current_time = do.getTimeId()

        program_name = "Program for Auto Test of Audit"  +current_time
        
        last_created_object_link = do.createObject("Program", program_name, "checked",True, config.username)
        #object_name = str(util.getTextFromXpathString(last_created_object_link)).strip() 
        
        # 2.  Navigate to that Program page
        #do.navigateToObjectWithSearch(program_name,"Program")
        do.navigateToObject("Program",last_created_object_link)
        util.max_screen()
         
        # 3. Select Regulations tab in Object pg Nav to bring up the Mapped Regulations widget
        # 4. Click +Regulation button to bring up modal selector for mapping Regulation to the Program
        do.navigateToMappingWindowForObject("Regulation")
        
        # 5. In modal, click green +Regulation button to bring up create a new Regulation modal
        util.clickOn(element.mapping_modal_add_button)
        
        # 6.  Fill in title for the new Regulation, "Regulation for Auto Test of Audit"
        # 7.  click Save (this dismisses the 2nd modal and puts the newly created Regulation at the top of the list in the 1st modal (the mapping modal)
        regulation_name = "Regulation for Auto Test of Audit"+current_time
        do.createObject("Regulation", regulation_name,"unchecked",False)
        
        # 8.  Select "Regulation for Auto test of Audit" at top of list then click Map button (dismisses modal and returns to Program pg now with the Regulation mapped)
        mapped_object_id = do.mapFirstObject("Regulation",False,regulation_name)
        
        # 9.  Click on Regulation for Auto Test of Audit in Mapped Regulations widget to expand the drop down and reveal Sections list
        #expand regulation area
        mapped_object_link = element.mapped_object.replace("OBJECT", "regulation").replace("ID", mapped_object_id)
        util.waitForElementToBePresent(mapped_object_link)
        self.assertTrue(util.isElementPresent(mapped_object_link),"doesn't see the newly created mapped object")
        util.clickOn(mapped_object_link)
        
        # 10.  Hover over +Sections link to reveal 3 options, then click on Create Section to launch the Create new Section modal
        # 11.  New Section modal:Title: "Section 1 of Regulation for Auto Test of Audit"
        # 12. Click Save - returns you to the Program pg > Regulation widget > Section now shows in revealed Sections display area
        do.createSectionFor("regulation",mapped_object_id,"Section 1 of Regulation for Auto Test of Audit"+current_time)
        section_id= do.getTheIdOfTheLastCreated("section")
        # 13. Click on "Section 1 of Regulation for Auto Test of Audit" title in the Sections display area - this reveals the Text of Section we entered and the "OBJECTIVES, CONTROLS, AND BUSINESS OBJECTS (0)" display area.
        #expand section area
        util.waitForElementToBePresent(element.sections_area_first_section)
        self.assertTrue(util.isElementPresent(element.sections_area_first_section),"doesn't see the newly created Section in the section area")
        util.clickOn(element.sections_area_first_section)
        self.assertTrue(util.isElementPresent(element.theShortDescriptionElement),"doesn't see the short description element")
        #make objectiveID link visible
        util.waitForElementToBePresent(element.section_area_add_object_link)
        self.assertTrue(util.isElementPresent(element.section_area_add_object_link),"doesn't see +Objective link")
        
        # 16. Repeat steps  14-15 3 times, increment Objective name, leave the next bullet point in description
        util.max_screen()
        for n in range(3):
            print "objective number " + str(n+1)
            # 14.  Hover over +Object to reveal 2 options

            util.scrollIntoView(element.section_area_add_object_link)
            util.hoverOverAndWaitFor(element.section_area_add_object_link, element.section_area_add_objective_link)
            self.assertTrue(util.isElementPresent(element.section_area_add_objective_link),"doesn't see the section_area_add_objective_link")
            
            # 15.  Click on +Objectives to open "Map New Objective to Section 1 of Regulation for Auto Test of Audit" modal, input data and click Save
            #util.clickOn(element.section_area_add_object_link)
            util.clickOn( element.section_area_add_objective_link)
        
            
            
            #create new objective
            do.createObjectives(grcobject.objective_title[n], grcobject.objective_description[n])
            last_created_object_element = element.objective_elemet_in_the_inner_tree_with_index.replace("INDEX",str(n+1 ))
            print "the last created objective element is "+last_created_object_element
            util.waitForElementToBePresent(last_created_object_element)
            self.assertTrue(util.isElementPresent(last_created_object_element), "cannot see the newly created objective")
            # store objectiveID ids
            objective_id= do.getTheIdOfTheLastCreatedObjective(last_created_object_element)
            objectiveID[n]=objective_id
            print objectiveID[n]
           
            

    
        # 17.after creating 3 Objectives, Hover over +Object 1 more time but this time click on +Object to launch the multi object mapper modal 
        
        #util.clickOnAndWaitFor(element.section_area_add_object_link, element.section_area_add_objective_link)
        util.clickOn(element.section_area_add_object_link)
        
        # 18.  Select Controls from top filter selector in modal
        util.selectFromDropdownByValue(element.mapping_modal_top_filter_selector_dropdown, "Control")
        
        # 19.  Click green +Control button to create a new control
        
        util.clickOn(element.mapping_modal_add_button)
        
        # 20.  Give it the title "Control for Auto Test of Audit" - Click Save
        control_name = "Control for Auto Test of Audit" +current_time
        do.createObject("Control", control_name,"unchecked",False)
        mapped_object_id= do.mapFirstObject("Control", False,control_name)
        print mapped_object_id
        
        #
        # Write audit setup data to file - program_name and the 3 objective ids, each on separate line
        #
        
        f=open("audit_setup_data","w")
        f.write(program_name+"\n")
        f.write(objectiveID[0]+"\n")
        f.write(objectiveID[1]+"\n")
        f.write(objectiveID[2]+"\n")
        f.close()
    def testProgramAuditInterviewRequest(self):
        self.testname="TestProgramAuditInterviewRequest"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers()
        do.setUtils(util)
        do.login()

        #
        # Read audit_setup_data to retrieve program name and the IDs of the 3 objectives
        #
        objectiveID={}
        f=open("audit_setup_data","r")
        program_name=f.readline().strip("\n")

        do.navigateToObjectWithSearch(program_name,"Program")
        util.max_screen()
        
        # 2.  Choose Audit from Object page nav to bring up the Audit widget
        do.navigateToAuditSectionViaInnerNavSection("Audit")
        newly_created_audit = element.audit_area_created_audit.replace("AUDIT_TITLE", "2014: program - Audit")
       
        print newly_created_audit
        util.waitForElementToBePresent(newly_created_audit)
        self.assertTrue(util.isElementPresent(newly_created_audit), "do not see the newly created audit " +"2014: program - Audit" )
        
        # 6. Click on it to open the 2nd tier info.  confirm there are 3 requests in the PBC Requests section. 
        newly_created_audit_open_link  = element.audit_area_created_audit_open_link.replace("AUDIT_TITLE", "2014: program - Audit")
        print newly_created_audit_open_link
        util.waitForElementToBePresent(newly_created_audit_open_link)
        self.assertTrue(util.isElementPresent(newly_created_audit_open_link), "do not see the newly created audit open link "  )
        util.clickOn(newly_created_audit_open_link)
        #util.switch_to_active_element()

        for objective_title in grcobject.objective_title:
            objective_title_element = element.audit_pbc_request.replace("TITLE", objective_title)
            print objective_title_element
            util.waitForElementToBePresent(objective_title_element)
            self.assertTrue(util.isElementPresent(objective_title_element), "do not see the pbc request " + objective_title_element )
            
                #7. Change Objective 2 for Auto test of Audit - Type: Interview
        
#         print "Change Objective 2 for Auto test of Audit - Type: Interview"
        objective2_select = element.audit_pbc_request_type_select.replace("TITLE",grcobject.objective_title[1] )
        objective2_selected_option = element.audit_pbc_request_type_select_selected_option.replace("TITLE",grcobject.objective_title[1] )
        """
        util.waitForElementToBePresent(objective2_select)
        util.selectFromDropdownUntilSelected(objective2_select,  "Interview")
        #verifying the selected option
        
        util.waitForElementToBePresent(objective2_selected_option)
        new_value = util.getTextFromXpathString(objective2_selected_option)
        self.assertTrue(new_value =="Interview" , "the selected option is not Interview" )
        """
        
        #click on "Objective 2 for Auto test of Audit" to open 2nd tier info
        print "click on Objective 2 for Auto test of Audit to open 2nd tier info"
        do.expandCollapseRequest(grcobject.objective_title[1])
        #click on Edit PBC Response
        util.waitForElementToBePresent(element.audit_pbc_request_expanded_content_edit_link)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_expanded_content_edit_link), "do not see the Edit link in the expanded request  "  )
        #click on Response to open that 2nd tier info
        response_element = element.audit_pbc_request_response.replace("TITLE",grcobject.objective_title[1] )
        print "response element " + response_element
        util.waitForElementToBePresent(response_element)
        self.assertTrue(util.isElementPresent(response_element), "do not see the Respond element in the expanded Request section for  "+ grcobject.objective_title[1]   )
        print "expanding response and Edit PBC Response "
        util.clickOn(response_element) #to expand the response
        util.waitForElementToBePresent(element.audit_pbc_request_expanded_response_edit_link)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_expanded_response_edit_link), "do not see the Edit PBS Response link in the expanded Request section for  "+ grcobject.objective_title[1]   )
        util.clickOn(element.audit_pbc_request_expanded_response_edit_link)
        #Delete
        print "deleting Response"
        do.deleteObject()
        #collapse back the request
        print "collapse back the request"
        do.expandCollapseRequest(grcobject.objective_title[1])
        time.sleep(3)
        util.selectFromDropdownUntilSelected(objective2_select,  "Interview")
        time.sleep(3)
        
        util.waitForElementToBePresent(objective2_selected_option)
        new_value = util.getTextFromXpathString(objective2_selected_option)
        self.assertTrue(new_value =="Interview" , "the selected option is not Interview" )
        
        #10.  Click on Objective 2 for Auto Test of Audit to open 2nd tier info (Interview)

        print "click on Objective 2 for Auto test of Audit to open 2nd tier info"
        do.expandCollapseRequest(grcobject.objective_title[1])
        objective2_select = element.audit_pbc_request_type_select.replace("TITLE",grcobject.objective_title[1] )
        util.waitForElementToBePresent(objective2_select)
        util.selectFromDropdownUntilSelected(objective2_select,  "Interview") # didn't work the first time
        print "Hover over +PBC Request then click on Create PBC Response to launch modal"
        add_pbc_response_link_within_the_objective = element.audit_pbc_request.replace("TITLE",grcobject.objective_title[1] )+element.section_add_link
        create_pbc_response_link_within_the_objective = element.audit_pbc_request.replace("TITLE",grcobject.objective_title[1] )+element.section_create_link
        util.waitForElementToBePresent(add_pbc_response_link_within_the_objective)
        util.scrollIntoView(add_pbc_response_link_within_the_objective)
        util.hoverOverAndWaitFor(add_pbc_response_link_within_the_objective,create_pbc_response_link_within_the_objective)
        util.clickOn(add_pbc_response_link_within_the_objective)
        util.clickOn(create_pbc_response_link_within_the_objective)
        #Description field :  "Response foir Interview Type", Save
        print "creating new interview response"
        do.NewResponseCreate("Response for Interview Type")
        #Click on Response for Interview Type header to reveal response 2nd tier info
      
         #click +Object to open Map Object Selector.  Change top filter to Org Group if neccessary (should not be).  Choose Reciprocity Dev Team and hit Map button. (use search to find this if easier to implement)
         #Confirm Reciprocity Dev Team is mapped to the Response and appears in the area provided

        
        
        #after creating a new response, the whole response section gets expanded automatically now, 
        #just need to wait for all elements to load (+Object, +Person, + Meeting)
        
        add_object_link = element.audit_pbc_request_response_add_object_link_within_response.replace("TITLE",grcobject.objective_title[1] )
        add_person_link = element.audit_pbc_request_response_add_person_within_response.replace("TITLE",grcobject.objective_title[1] )
        add_meeting_link = element.audit_pbc_request_response_add_meeting.replace("TITLE",grcobject.objective_title[1] )
        util.waitForElementToBePresent(add_object_link)
        self.assertTrue(util.isElementPresent(add_object_link), "do not see the open close button for the response")
        util.waitForElementToBePresent(add_person_link)
        self.assertTrue(util.isElementPresent(add_person_link), "do not see the + Person link")
        util.waitForElementToBePresent(add_meeting_link)
        self.assertTrue(util.isElementPresent(add_meeting_link), "do not see the + Meeting link")
        
        #click +Object to open Map Object Selector. 
        util.clickOn(add_object_link)
         
        #Change top filter to Org Group. 
        util.waitForElementToBePresent(element.mapping_modal_window)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window), "do not see the modal window")
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown), "do not see the modal window")
        util.selectFromDropdownByValue(element.mapping_modal_top_filter_selector_dropdown, "OrgGroup")
        
        #Choose Reciprocity Dev Team and hit Map button. (use search to find this if easier to implement)
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option), "do not see the open close button for the response")
        util.clickOn(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        util.waitForElementToBePresent(element.mapping_modal_window_map_button)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window_map_button), "no Map button")
        util.clickOn(element.mapping_modal_window_map_button)
        util.waitForElementNotToBePresent(element.mapping_modal_window)
        
         #Confirm Reciprocity Dev Team is mapped to the Response and appears in the area provided
        util.waitForElementToBePresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team), "no Mapped org group button")
        
        
        #click on +Person link to launch Map People modal
        print "click on +Person link to launch Map People modal"
        #add_person_link = element.audit_pbc_request_response_add_person_within_response.replace("TITLE",grcobject.objective_title[1] )
        util.waitForElementToBePresent(add_person_link)
        self.assertTrue(util.isElementPresent(add_person_link), "do not see the + Person link")
        util.clickOn(add_person_link)
        
        #search for "silas"
        print "searching and mapping another participant"
        person_email=do.mapPerson("silas")
        
        #confirm silas has been added to Participant area
        print "confirming another participant has been mapped"
        participant_email = element.audit_pbc_request_response_participant_email.replace("EMAIL",person_email)
        util.waitForElementToBePresent(participant_email)
        self.assertTrue(util.isElementPresent(participant_email), "do not see the Person Mapped email")
        
        #click on +Meetings in Meetings area
        print "click on +Meetings in Meetings area"
        
        add_meeting_link = element.audit_pbc_request_response_add_meeting.replace("TITLE",grcobject.objective_title[1] )
        print "add meeting link is " +add_meeting_link
        util.waitForElementToBePresent(add_meeting_link)
        self.assertTrue(util.isElementPresent(add_meeting_link), "do not see +Meeting link")
        create_meeting_link = element.audit_pbc_request_response_create_meeting.replace("TITLE",grcobject.objective_title[1] )
        util.scrollIntoView(add_meeting_link)
        util.scrollIntoView(add_meeting_link)
        util.move_mouse_over(add_meeting_link)
        util.scrollIntoView(add_meeting_link)
        util.hoverOver(add_meeting_link)
        util.clickOn(create_meeting_link)
        
        meeting_date = (date.today())+ datetime.timedelta(days=14)
        meeting_date_into_format = do.convertDateIntoFormat(meeting_date)
        
        #Enter Title:  Auto Test of Audit - Interview Response - Scheduling a meeting, Choose date : current date + 2 weeks, Set start time to 12pm, Set end time to 1pm, Confirm particpants are silas and testrecip
        do.scheduleMeeting("Auto Test of Audit - Interview Response - Scheduling a meeting-"+strftime("%Y_%m_%d__%H_%M_%S"),meeting_date_into_format, "03:00 PM", "04:00 PM")
        #do.closeOtherWindows()
        #util.switch_to_active_element()
        util.focus()
        util.waitForElementToBePresent(element.meeting_expnad_link)
        util.clickOn(element.meeting_expnad_link)
        
        do.verifyMeetingData(meeting_date_into_format, "03:00 PM", "04:00 PM")
Ejemplo n.º 4
0
    def testProgramAudit(self):
        self.testname="TestProgramAudit"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers()
        do.setUtils(util)
        do.login()

        #
        # Read audit_setup_data to retrieve program name and the IDs of the 3 objectives
        #
        objectiveID={}
        # default to using setup file for TEST server
        setup_file = SETUP_FILE_PREFIX + TARGET_SERVER_DICT.get(config.url, "test")
        f = open(os.path.join(SETUP_DIR, setup_file), "r")
        program_name=f.readline().strip("\n")
        ##objectiveID[0]=int(f.readline().strip("\n"))
        #objectiveID[1]=int(f.readline().strip("\n"))
        #objectiveID[2]=int(f.readline().strip("\n"))
        #print program_name
        #print objectiveID
        
        
        
        # 1.  Navigate to the Program page created in Audit Part 1
        #first_program_in_lhn = '//ul[@class="top-level"]//li[contains(@data-model-name,"Program")]//li[contains(.,"NAME")]/a'.replace("NAME", program_name)
        #print first_program_in_lhn
        do.navigateToObjectWithSearch(program_name,"Program")
        util.max_screen()
        
        # 2.  Choose Audit from Object page nav to bring up the Audit widget
        do.navigateToAuditSectionViaInnerNavSection("Audit")

        # 3.  Click on blue +Audit link in widget
        util.clickOn(element.audit_area_plus_audit_link)
                     
        # 4.  New Audit (modal)
        new_audit_title = do.createAudit(program_name)
        
        # 5.  Confirm the audit appear in the widget
        newly_created_audit = element.audit_area_created_audit.replace("AUDIT_TITLE", new_audit_title)
        print newly_created_audit
        util.waitForElementToBePresent(newly_created_audit)
        self.assertTrue(util.isElementPresent(newly_created_audit), "do not see the newly created audit " +new_audit_title )
        
        # 6. Click on it to open the 2nd tier info.  confirm there are 3 requests in the PBC Requests section. 
        newly_created_audit_open_link  = element.audit_area_created_audit_open_link.replace("AUDIT_TITLE", new_audit_title)
        print newly_created_audit_open_link
        util.waitForElementToBePresent(newly_created_audit_open_link)
        self.assertTrue(util.isElementPresent(newly_created_audit_open_link), "do not see the newly created audit open link "  )
        util.clickOn(newly_created_audit_open_link)
        util.switch_to_active_element()
        util.max_screen()
        #verifying the 3 objectives
        
        for objective_title in grcobject.objective_title:
            objective_title_element = element.audit_pbc_request.replace("TITLE", objective_title)
            print objective_title_element
            util.waitForElementToBePresent(objective_title_element)
            self.assertTrue(util.isElementPresent(objective_title_element), "do not see the pbc request " + objective_title_element )
        
        do.waitForAlertSuccessMessages()
        
        #7. Change Objective 2 for Auto test of Audit - Type: Interview
        print "Change Objective 2 for Auto test of Audit - Type: Interview"
        objective2_select = element.audit_pbc_request_type_select.replace("TITLE",grcobject.objective_title[1] )
        objective2_selected_option = element.audit_pbc_request_type_select_selected_option.replace("TITLE",grcobject.objective_title[1] )
        util.waitForElementToBePresent(objective2_select)
        util.selectFromDropdownUntilSelected(objective2_select,  "Interview")
        #verifying the selected option
        
        util.waitForElementToBePresent(objective2_selected_option)
        new_value = util.getTextFromXpathString(objective2_selected_option)
        self.assertTrue(new_value =="Interview" , "the selected option is not Interview" )
        
        #click on "Objective 2 for Auto test of Audit" to open 2nd tier info
        print "click on Objective 2 for Auto test of Audit to open 2nd tier info"
        do.expandCollapseRequest(grcobject.objective_title[1])
        #click on Edit PBC Response
        util.waitForElementToBePresent(element.audit_pbc_request_expanded_content_edit_link)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_expanded_content_edit_link), "do not see the Edit link in the expanded request  "  )
        #click on Response to open that 2nd tier info
        response_element = element.audit_pbc_request_response.replace("TITLE",grcobject.objective_title[1] )
        print "response element " + response_element
        util.waitForElementToBePresent(response_element)
        self.assertTrue(util.isElementPresent(response_element), "do not see the Respond element in the expanded Request section for  "+ grcobject.objective_title[1]   )
        print "expanding response and Edit PBC Response "
        util.clickOn(response_element) #to expand the response
        util.waitForElementToBePresent(element.audit_pbc_request_expanded_response_edit_link)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_expanded_response_edit_link), "do not see the Edit PBS Response link in the expanded Request section for  "+ grcobject.objective_title[1]   )
        util.clickOn(element.audit_pbc_request_expanded_response_edit_link)
        #Delete
        print "deleting Response"
        do.deleteObject()
        #collapse back the request
        print "collapse back the request"
        do.expandCollapseRequest(grcobject.objective_title[1])
        time.sleep(3)
        util.selectFromDropdownUntilSelected(objective2_select,  "Interview")
        time.sleep(3)
        
        util.waitForElementToBePresent(objective2_selected_option)
        new_value = util.getTextFromXpathString(objective2_selected_option)
        self.assertTrue(new_value =="Interview" , "the selected option is not Interview" )
        
         #8. Change Objective 3 for Auto test of Audit - Type: Population Sample
        objective3_select = element.audit_pbc_request_type_select.replace("TITLE",grcobject.objective_title[2] )
        util.waitForElementToBePresent(objective3_select)
        print "Change Objective 3 for Auto test of Audit - Type: Population Sample"
        #util.selectFromDropdownUntilSelected(objective3_select,  "Population Sample")
        #click on "Objective 3 for Auto test of Audit" to open 2nd tier info
        
        do.expandCollapseRequest(grcobject.objective_title[2])
        #click on Edit PBC Response
        util.waitForElementToBePresent(element.audit_pbc_request_expanded_content_edit_link)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_expanded_content_edit_link), "do not see the Edit link in the expanded request  "  )
        #click on Response to open that 2nd tier info
        response_element = element.audit_pbc_request_response.replace("TITLE",grcobject.objective_title[2] )
        print "response element " + response_element
        util.waitForElementToBePresent(response_element)
        self.assertTrue(util.isElementPresent(response_element), "do not see the Respond element in the expanded Request section for  "+ grcobject.objective_title[2]   )
        print "expanding response and Edit PBC Response "
        util.clickOn(response_element) #to expand the response
        util.waitForElementToBePresent(element.audit_pbc_request_expanded_response_edit_link)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_expanded_response_edit_link), "do not see the Edit PBS Response link in the expanded Request section for  "+ grcobject.objective_title[2]   )
        util.clickOn(element.audit_pbc_request_expanded_response_edit_link)
        #Delete
        print "deleting Response"
        do.deleteObject()
        #collapse back the request
        print "collapse back the request"
       
        do.expandCollapseRequest(grcobject.objective_title[2])
        time.sleep(5)
        util.selectFromDropdownUntilSelected(objective3_select,  "Population Sample")
        
        #taking a screenshot
        util.switch_to_active_element()
        util.get_a_screen_shot("test_screenshot.png")
        
        #9.    Click on Objective 1 for Auto Test of Audit to open 2nd tier info (Documentation Response)
        do.expandCollapseRequest(grcobject.objective_title[0])
        response_element = element.audit_pbc_request_response.replace("TITLE",grcobject.objective_title[0] )
        print "response element " + response_element
        #util.waitForElementToBePresent(element.audit_pbc_request_expanded_content_response_email_inputfield)
        util.waitForElementValueToBePresent(response_element)
        
        self.assertTrue(util.isElementPresent(response_element), "can't see the expanded contetnt for the request link") 
        util.waitForElementToBePresent(response_element)
        #self.assertTrue(util.isElementPresent(element.audit_pbc_request_response), "do not see the firts response presented")
            
       
        #.    Assign that Response to another team member ([email protected] is fine)
        response_email_inputfield = element.audit_pbc_request_expanded_content_response_email_inputfield.replace("TITLE",grcobject.objective_title[0] )
        print "response_email_inputfield " + response_email_inputfield
        util.waitForElementToBePresent(response_email_inputfield)
        self.assertTrue(util.isElementPresent(response_email_inputfield), "do not see the firts response owner email textfield presented")
        util.inputTextIntoField("*****@*****.**", response_email_inputfield)
        
        #Click on the response header to open the response
        open_response_link = element.audit_pbc_request_response_expand_collapse_link.replace("TITLE",grcobject.objective_title[0] )
        util.waitForElementToBePresent(open_response_link)
        self.assertTrue(util.isElementPresent(open_response_link), "do not see the open close button for the response")
        util.clickOn(open_response_link)
        
        #click +Object to open Map Object Selector. 
        add_object_link = element.audit_pbc_request_response_add_object_link.replace("TITLE",grcobject.objective_title[0] )
        util.waitForElementToBePresent(add_object_link)
        self.assertTrue(util.isElementPresent(add_object_link), "do not see the open close button for the response")
        util.clickOn(add_object_link)
        
        #Change top filter to Org Group. 
        util.waitForElementToBePresent(element.mapping_modal_window)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window), "do not see the modal window")
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown), "do not see the modal window")
        util.selectFromDropdownByValue(element.mapping_modal_top_filter_selector_dropdown, "OrgGroup")
        
        #Choose Reciprocity Dev Team and hit Map button. (use search to find this if easier to implement)
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option), "do not see the open close button for the response")
        util.clickOn(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        util.waitForElementToBePresent(element.mapping_modal_window_map_button)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window_map_button), "no Map button")
        util.clickOn(element.mapping_modal_window_map_button)
        util.waitForElementNotToBePresent(element.mapping_modal_window)
        
         #Confirm Reciprocity Dev Team is mapped to the Response and appears in the area provided
        util.waitForElementToBePresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team), "no Mapped org group button")
        
        #Click +Upload Evidence in the Evidence area to open the file picker
        upload_evidence_link = element.audit_pbc_request_response_upload_evidence_link.replace("TITLE",grcobject.objective_title[0] )
        util.waitForElementToBePresent(upload_evidence_link)
        self.assertTrue(util.isElementPresent(upload_evidence_link), "no Upload Evidence link")
        util.clickOn(upload_evidence_link)
        util.waitForElementToBePresent('//iFrame[@class="picker-frame picker-dialog-frame"]')
        #self.assertTrue(util.isElementPresent('//iFrame[@class="picker-frame picker-dialog-frame"]'), "no Upload window")
        url=util.getAnyAttribute('//iFrame[@class="picker-frame picker-dialog-frame"]', "src")
        print url
        util.switchToNewUrl(url)
        file_is = os.getcwd() + "/test_screenshot.png"
        util.uploadItem(file_is, element.select_file_button)
        util.waitForElementToBeVisible(element.upload_file_button)
        util.find_element_by_xpath(element.upload_file_button).click() 
        time.sleep(10) # wait for uploading the file
        util.backBrowser()
        util.refreshPage()
        #waiting to audit to appear back
        newly_created_audit = element.audit_area_created_audit.replace("AUDIT_TITLE", new_audit_title)
        print newly_created_audit
        util.waitForElementToBePresent(newly_created_audit)
        self.assertTrue(util.isElementPresent(newly_created_audit), "do not see the newly created audit " +new_audit_title )
         
        newly_created_audit_open_link  = element.audit_area_created_audit_open_link.replace("AUDIT_TITLE", new_audit_title)
        print newly_created_audit_open_link
        util.waitForElementToBePresent(newly_created_audit_open_link)
        self.assertTrue(util.isElementPresent(newly_created_audit_open_link), "do not see the newly created audit open link "  )
        util.clickOn(newly_created_audit_open_link)
        util.switch_to_active_element()
        #expand objetiive 1 to verify the uploaded file
        do.expandCollapseRequest(grcobject.objective_title[0])
        evidence_folder_link = element.audit_pb_request_response_evidence_folder_link.replace("TITLE",grcobject.objective_title[0] )
        util.waitForElementToBePresent(evidence_folder_link)
        self.assertTrue(util.isElementPresent(evidence_folder_link), "do not see the evidene folder link "  )
        do.expandCollapseRequest(grcobject.objective_title[0])
        time.sleep(2)
        
        #10.  Click on Objective 2 for Auto Test of Audit to open 2nd tier info (Interview)

        print "click on Objective 2 for Auto test of Audit to open 2nd tier info"
        do.expandCollapseRequest(grcobject.objective_title[1])
        objective2_select = element.audit_pbc_request_type_select.replace("TITLE",grcobject.objective_title[1] )
        util.waitForElementToBePresent(objective2_select)
        util.selectFromDropdownUntilSelected(objective2_select,  "Interview") # didn't work the first time
        print "Hover over +PBC Request then click on Create PBC Response to launch modal"
        add_pbc_response_link_within_the_objective = element.audit_pbc_request.replace("TITLE",grcobject.objective_title[1] )+element.section_add_link
        create_pbc_response_link_within_the_objective = element.audit_pbc_request.replace("TITLE",grcobject.objective_title[1] )+element.section_create_link
        util.waitForElementToBePresent(add_pbc_response_link_within_the_objective)
        util.scrollIntoView(add_pbc_response_link_within_the_objective)
        util.hoverOverAndWaitFor(add_pbc_response_link_within_the_objective,create_pbc_response_link_within_the_objective)
        util.clickOn(add_pbc_response_link_within_the_objective)
        util.clickOn(create_pbc_response_link_within_the_objective)
        #Description field :  "Response foir Interview Type", Save
        print "creating new interview response"
        do.NewResponseCreate("Response for Interview Type")
        #Click on Response for Interview Type header to reveal response 2nd tier info
      
         #click +Object to open Map Object Selector.  Change top filter to Org Group if neccessary (should not be).  Choose Reciprocity Dev Team and hit Map button. (use search to find this if easier to implement)
         #Confirm Reciprocity Dev Team is mapped to the Response and appears in the area provided

        
        
        #after creating a new response, the whole response section gets expanded automatically now, 
        #just need to wait for all elements to load (+Object, +Person, + Meeting)
        
        add_object_link = element.audit_pbc_request_response_add_object_link_within_response.replace("TITLE",grcobject.objective_title[1] )
        add_person_link = element.audit_pbc_request_response_add_person_within_response.replace("TITLE",grcobject.objective_title[1] )
        add_meeting_link = element.audit_pbc_request_response_add_meeting.replace("TITLE",grcobject.objective_title[1] )
        util.waitForElementToBePresent(add_object_link)
        self.assertTrue(util.isElementPresent(add_object_link), "do not see the open close button for the response")
        util.waitForElementToBePresent(add_person_link)
        self.assertTrue(util.isElementPresent(add_person_link), "do not see the + Person link")
        util.waitForElementToBePresent(add_meeting_link)
        self.assertTrue(util.isElementPresent(add_meeting_link), "do not see the + Meeting link")
        
        #click +Object to open Map Object Selector. 
        util.clickOn(add_object_link)
         
        #Change top filter to Org Group. 
        util.waitForElementToBePresent(element.mapping_modal_window)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window), "do not see the modal window")
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown), "do not see the modal window")
        util.selectFromDropdownByValue(element.mapping_modal_top_filter_selector_dropdown, "OrgGroup")
        
        #Choose Reciprocity Dev Team and hit Map button. (use search to find this if easier to implement)
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option), "do not see the open close button for the response")
        util.clickOn(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        util.waitForElementToBePresent(element.mapping_modal_window_map_button)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window_map_button), "no Map button")
        util.clickOn(element.mapping_modal_window_map_button)
        util.waitForElementNotToBePresent(element.mapping_modal_window)
        
         #Confirm Reciprocity Dev Team is mapped to the Response and appears in the area provided
        util.waitForElementToBePresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team), "no Mapped org group button")
        
        
        #click on +Person link to launch Map People modal
        print "click on +Person link to launch Map People modal"
        #add_person_link = element.audit_pbc_request_response_add_person_within_response.replace("TITLE",grcobject.objective_title[1] )
        util.waitForElementToBePresent(add_person_link)
        self.assertTrue(util.isElementPresent(add_person_link), "do not see the + Person link")
        util.clickOn(add_person_link)
        
        #search for "silas"
        print "searching and mapping another participant"
        person_email=do.mapPerson("silas")
        
        #confirm silas has been added to Participant area
        print "confirming another participant has been mapped"
        participant_email = element.audit_pbc_request_response_participant_email.replace("EMAIL",person_email)
        util.waitForElementToBePresent(participant_email)
        self.assertTrue(util.isElementPresent(participant_email), "do not see the Person Mapped email")
        
        #click on +Meetings in Meetings area
        print "click on +Meetings in Meetings area"
        
        add_meeting_link = element.audit_pbc_request_response_add_meeting.replace("TITLE",grcobject.objective_title[1] )
        print "add meeting link is " +add_meeting_link
        util.waitForElementToBePresent(add_meeting_link)
        self.assertTrue(util.isElementPresent(add_meeting_link), "do not see +Meeting link")
        create_meeting_link = element.audit_pbc_request_response_create_meeting.replace("TITLE",grcobject.objective_title[1] )
        util.scrollIntoView(add_meeting_link)
        util.scrollIntoView(add_meeting_link)
        util.move_mouse_over(add_meeting_link)
        util.scrollIntoView(add_meeting_link)
        util.hoverOver(add_meeting_link)
        util.clickOn(create_meeting_link)
        
        meeting_date = (date.today())+ datetime.timedelta(days=14)
        meeting_date_into_format = do.convertDateIntoFormat(meeting_date)
        
        #Enter Title:  Auto Test of Audit - Interview Response - Scheduling a meeting, Choose date : current date + 2 weeks, Set start time to 12pm, Set end time to 1pm, Confirm particpants are silas and testrecip
        do.scheduleMeeting("Auto Test of Audit - Interview Response - Scheduling a meeting-"+strftime("%Y_%m_%d__%H_%M_%S"),meeting_date_into_format, "03:00 PM", "04:00 PM")
        #do.closeOtherWindows()
        #util.switch_to_active_element()
        util.focus()
        util.waitForElementToBePresent(element.meeting_expnad_link)
        util.clickOn(element.meeting_expnad_link)
        
        do.verifyMeetingData(meeting_date_into_format, "03:00 PM", "04:00 PM")

        do.expandCollapseRequest(grcobject.objective_title[1])

        
        time.sleep(3)
        #11. Click on Objective 3 for Auto Test of Audit to open 2nd tier info (Population Sample)
        print "11. Click on Objective 3 for Auto Test of Audit to open 2nd tier info (Population Sample)"
        do.expandCollapseRequest(grcobject.objective_title[2])
        print "Hover over +PBC Request then click on Create PBC Response to launch modal"
        add_pbc_response_link_within_the_objective = element.audit_pbc_request.replace("TITLE",grcobject.objective_title[2] )+element.section_add_link
        create_pbc_response_link_within_the_objective = element.audit_pbc_request.replace("TITLE",grcobject.objective_title[2] )+element.section_create_link
        util.waitForElementToBePresent(add_pbc_response_link_within_the_objective)
        util.scrollIntoView(add_pbc_response_link_within_the_objective)
        util.hoverOverAndWaitFor(add_pbc_response_link_within_the_objective,create_pbc_response_link_within_the_objective)
        util.clickOn(add_pbc_response_link_within_the_objective)
        util.clickOn(create_pbc_response_link_within_the_objective)
        #Description field :  ""Response for Population Sample Type"", Save
        print "creating new interview response"
        do.NewResponseCreate("Response for Population Sample Type")
        
        #click +Object to open Map Object Selector. 
        add_object_link = element.audit_pbc_request_response_add_object_link_within_response.replace("TITLE",grcobject.objective_title[2] )
        util.waitForElementToBePresent(add_object_link)
        util.clickOn(add_object_link)
         
        
        #Change top filter to Org Group. 
        util.waitForElementToBePresent(element.mapping_modal_window)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window), "do not see the modal window")
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown), "do not see the modal window")
        util.clickOn(element.mapping_modal_search_reset)
        util.selectFromDropdownByValue(element.mapping_modal_top_filter_selector_dropdown, "OrgGroup")
        
        #Choose Reciprocity Dev Team and hit Map button. (use search to find this if easier to implement)
        util.waitForElementToBePresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        self.assertTrue(util.isElementPresent(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option), "do not see the open close button for the response")
        util.clickOn(element.mapping_modal_top_filter_selector_dropdown_reciprocity_dev_team_option)
        util.waitForElementToBePresent(element.mapping_modal_window_map_button)
        self.assertTrue(util.isElementPresent(element.mapping_modal_window_map_button), "no Map button")
        util.clickOn(element.mapping_modal_window_map_button)
        util.waitForElementNotToBePresent(element.mapping_modal_window)
        
         #Confirm Reciprocity Dev Team is mapped to the Response and appears in the area provided
        util.waitForElementToBePresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team)
        self.assertTrue(util.isElementPresent(element.audit_pbc_request_response_mapped_org_group_object_withrecipprocity_dev_team), "no Mapped org group button")