def testImportExportSystem(self):
        self.testname="TestImportExportSystem"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        do = Helpers(self)
        do.setUtils(util)
        do.login()

        # create a system
        systemObject =do.createObject("System")
        systemObject = str(util.getTextFromXpathString(systemObject)) #it's name, not xpath
        
        print ""
        print "On screen."
        print "System object is displayed as : " + systemObject
     
# export system
        filePath = config.test_db + "SYSTEMS.csv"
        do.selectMenuInTopRight("Admin Dashboard")
        do.exportFile("systems", filePath)
               
        # verify that information in file matched
        self.assertTrue(do.verifyDataInExportFile(systemObject, filePath), "System object not found in exported file.")
   
# import system
        # create some data, add it to the import file and upload       
        number = str(do.getRandomNumber())
        systemObject = "systemImport" + number
      
        print ""
        print "Add this new system object to the import file and upload."
        print "System object: " + systemObject
       
        # proof: verify that this user never exist in the database
        do.navigateToObjectWithSearchWithNoAssertion(systemObject, "System")
        count = do.countOfAnyObjectLHS("System")
        self.assertEqual(0, count, "System " + systemObject + " is verified not existed.")
             
        # make it complete     
        conformingText = "SYSTEM-" + number + "," + systemObject + ",,,,,,[email protected],,,,,,2014-7-16,2014-7-16,,Draft"        
        do.appendToFile(conformingText, filePath)
        
        do.importFile("Systems", filePath)
        do.refresh()   
        
        # after import, verify that user has been added to the database
        do.navigateToObjectWithSearch(systemObject, "System")
        count = do.countOfAnyObjectLHS("System")
        self.assertEqual(1, count, "System " + systemObject + " is not added successfully.")
        self.assertEqual(systemObject, do.getObjectNavWidgetInfo("username"), "System object " + systemObject + " is not found in the database.")

 
        print ""
        print "System object is imported successfully and found in the database."
        print systemObject
    def testImportExportPeople(self):
        self.testname="TestImportExportPeople"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        do = Helpers(self)
        do.setUtils(util)
        do.login()

        # create a person
        number = str(do.getRandomNumber())
        aEmail = "email" + number + "@gmail.com"
        aName =  "name" + number   
        aCompany = "company" + number              
        do.createPersonLHN(aName, aEmail, aCompany)

        do.uncheckMyWorkBox()
        do.navigateToObjectWithSearch(aName, "Person")
        
        print ""
        print "On screen."
        print "User is displayed as : " + aName
        print "Email is displayed as : " + aEmail
        print "Company is displayed as : " + aCompany
        
# export people
        filePath = config.test_db + "PEOPLE.csv"
        print filePath
        do.selectMenuInTopRight("Admin Dashboard")
        do.exportFile("people", filePath)
               
        # verify that information in file matched
        self.assertTrue(do.verifyPeopleExportFile(aName, aEmail, aCompany, filePath), "User not found in exported file.")
   
# import people
        # create some data, add it to the import file and upload       
        number = str(do.getRandomNumber())
        aEmail = "emailImport" + number + "@gmail.com"
        aName =  "nameImport" + number   
        aCompany = "companyImport" + number  
        
        print ""
        print "Add this new user info to the import file and upload."
        print "User name: " + aName
        print "Email: " + aEmail
        print "Company: " + aCompany
        userInfo = aName + "," + aEmail + "," + aCompany
        
        # proof: verify that this user never exist in the database
        do.navigateToObjectWithSearchWithNoAssertion(aName, "Person")
        count = do.countOfAnyObjectLHS("Person")
        self.assertEqual(0, count, "User " + aName + " is verified not existed.")
                
        do.appendToFile(userInfo, filePath)
        do.importFile("People", filePath)
        do.refresh()   
        
        # after import, verify that user has been added to the database
        do.navigateToObjectWithSearch(aName, "Person")
        count = do.countOfAnyObjectLHS("Person")
        self.assertEqual(1, count, "User " + aName + " is verified not existed.")
        self.assertEqual(aName, do.getObjectNavWidgetInfo("username"), "User's name " + aName + " is not found in the database.")
        self.assertEqual(aEmail, do.getObjectNavWidgetInfo("email"), "User's email " + aEmail + " is not found in the database.")
        self.assertEqual(aCompany, do.getObjectNavWidgetInfo("company"), "User's company " + aCompany + " is not found in the database.")
        
        print ""
        print "User is imported successfully and found in the database."
        print aName + "," + aEmail + "," + aCompany
示例#3
0
    def testProgramAudit(self):
        self.testname="TestProgramAudit"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        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")
        # 1.  Navigate to the Program page created in Audit Part 1
        #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)
        do.authorizeGAPI()  # Another place GAPI dialog could pop up
        new_audit_title = do.createAudit(program_name)
        
        # 5.  Confirm the audit appear in the widget
        newly_created_audit = element.audit_area_by_title.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. 
        # GAPI could pop up here
        do.authorizeGAPI()
        util.scrollIntoView(newly_created_audit)
        util.clickOn(newly_created_audit + element.first_link_within)
        #util.switch_to_active_element()
        util.max_screen()
        util.scrollIntoView(newly_created_audit)
        #verifying the 3 objectives
        
        do.dismissFlashMessages()
        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.scrollIntoView(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"
        #### navigate into PBC edit modal
        ####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 Request
        ###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  "  )
        ###util.clickOn(element.audit_pbc_request_expanded_content_edit_link)
        ###objective2_selected_option = element.audit_pbc_request_modal_type_select_selected_option
        ###util.waitForElementToBePresent(element.audit_pbc_request_modal_type_select)
        ###util.selectFromDropdownUntilSelected(element.audit_pbc_request_modal_type_select,  "Interview")
        ####verifying the selected option
        ###
        ###util.waitForElementToBePresent(objective2_selected_option)
        ###do.saveObjectData()
        ###util.clickOn(element.audit_pbc_request_expanded_content_edit_link)
        ###new_value = util.getTextFromXpathString(objective2_selected_option)
        ###self.assertTrue(new_value =="Interview" , "the selected option is not Interview" )

        ####Delete
        ###print "deleting Request"
        ###do.deleteObject()
        ### #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] )
        ###do.expandCollapseRequest(grcobject.objective_title[2])
        ####click on Edit PBC Request
        ###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  "  )
        ###util.clickOn(element.audit_pbc_request_expanded_content_edit_link)
        ###objective3_selected_option = element.audit_pbc_request_modal_type_select_selected_option
        ###util.waitForElementToBePresent(element.audit_pbc_request_modal_type_select)
        ###util.selectFromDropdownUntilSelected(element.audit_pbc_request_modal_type_select,  "Population Sample")
        ####verifying the selected option
        ###
        ###util.waitForElementToBePresent(objective3_selected_option)
        ###do.saveObjectData()
        ###util.clickOn(element.audit_pbc_request_expanded_content_edit_link)
        ###new_value = util.getTextFromXpathString(objective2_selected_option)
        ###self.assertTrue(new_value == "Population Sample" , "the selected option is not Population Sample" )



        ####Delete
        ###print "deleting Response"
        ###do.deleteObject()
        
        #9.    Click on Objective 1 for Auto Test of Audit to open 2nd tier info (Documentation Response)
        #util.scrollIntoView(newly_created_audit_open_link)
        do.expandCollapseRequest(grcobject.objective_title[0])
        do.setRequestToRespondable(grcobject.objective_title[0])
        # open the response model and fill it out
        new_response_button = element.audit_pbc_request_response_create.replace("TITLE", grcobject.objective_title[0])
        util.waitForElementToBePresent(new_response_button)
        util.clickOn(new_response_button)
        new_response_title = "Response to " + grcobject.objective_title[0]
        do.NewResponseCreate(new_response_title)

        response_element = element.audit_pbc_request_response2.replace("TITLE", grcobject.objective_title[0]).replace("RESPONSE", new_response_title)
        print "response element " + response_element
        util.waitForElementToBePresent(response_element)
        util.scrollIntoView(response_element)  
        time.sleep(20)
        self.assertTrue(util.isElementPresent(response_element), "can't see the new Response for the request link") 

        # look for edit button
        new_response_edit_link = element.audit_pbc_request_expanded_response_edit_link2.replace("TITLE", grcobject.objective_title[0]).replace("RESPONSE", new_response_title)
        util.waitForElementToBePresent(new_response_edit_link)
        util.clickOn(new_response_edit_link)
        # need to re-open
        # verify assignee is the same as audit lead ([email protected])
        pbc_response_elements = {
            # name is description, but functions more like a title in
            # the context of the verifyObjectValues helper
            "description": element.response_title,
            "owner": element.response_assignee,
        }

        pbc_response_values = {
            "description": new_response_title,
            "owner": do.current_user_email(),
        }
        do.verifyObjectValues(pbc_response_elements, pbc_response_values, "Audit")
        do.saveObjectData()
        audit_edit_button = newly_created_audit + element.audit_edit
        util.scrollIntoView(audit_edit_button)
        util.clickOn(audit_edit_button)
        do.deleteObject()
    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_by_title.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_by_title.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_by_title.replace("AUDIT_TITLE", "2014: program - Audit")
        #newly_created_audit = element.audit_area_by_title.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_by_title.replace("AUDIT_TITLE", "2014: program - Audit") 
        #newly_created_audit_open_link  = element.audit_area_by_title.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])
示例#5
0
    def testRelevantMapping(self):
        self.testname="TestRelevantMapping"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()

        # mapping and un-mapping up to 3 levels: 
        # Program->Policy->Section->Object
        titlePol = do.getUniqueString("policy") #regulation
        titlePrgm = do.getUniqueString("program")
        titleSec = do.getUniqueString("section")
        titleMkt = do.getUniqueString("market")
       
        print "Policy: " + titlePol
        print "Program: " + titlePrgm
        print "Section: " + titleSec
        print "Market: " + titleMkt
                    
        # SETUP
        do.createObject("Market", titleMkt) 
        do.createObject("Policy", titlePol)  
        last_created_object_link = do.createObject("Program", titlePrgm)
        do.mapAObjectLHN("Policy", titlePol)  # maps to a Policy object
        do.expandItemWidget("Policy", titlePol)  # expand the item so that "+ Section" link is displayed
        do.createSectionFromInnerNavLink(titleSec)
        do.mapObjectToSectionFromInnerNav(titleSec)
        do.mapObjectFormFilling("Market", titleMkt)
        do.expandWidget4thTier(titleMkt)
        
        # Policy page
        do.navigateToObjectWithSearch(titlePol, "Policy")
        do.navigateToInnerNavSection("Market")
        do.assertEqual(0, do.countOfAnyObjectInWidget("market"), "Count is not 0 in Widget.")
        do.assertEqual(0, do.countOfAnyObjectInnerNav("market"), "Count is not 0 in InnerNav.")
         
        # Verification: you don't see person object from Program page
        # 1 because the creator is automatically mapped to the program
        do.navigateToObjectWithSearch(titlePrgm, "Program")
        do.navigateToInnerNavSection("Market")
        do.assertEqual(1, do.countOfAnyObjectInWidget("market"), "Count is not 1 in Widget.")
        do.assertEqual(1, do.countOfAnyObjectInnerNav("market"), "Count is not 1 in InnerNav.")  
    
        # Verification: you see Market object in Section page
        do.navigateToObjectWithSearch(titleSec, "Section")
        do.navigateToInnerNavSection("Market")
        do.assertEqual(titleMkt, do.getTitleFromWidgetList(1, "Section"))
        do.assertEqual(1, do.countOfAnyObjectInWidget("market"), "Count is not 1 in Widget.")
        do.assertEqual(1, do.countOfAnyObjectInnerNav("market"), "Count is not 1 in InnerNav.") 
         
        # Verification: you see section object from People page
        do.uncheckMyWorkBox()        
        do.navigateToObjectWithSearch(titleMkt, "Market")
        do.navigateToInnerNavSection("Section")
        do.assertEqual(titleSec, do.getTitleFromWidgetList(1, "Market")) #STOP HERE
        do.assertEqual(1, do.countOfAnyObjectInWidget("section"), "Count is not 1 in Widget.")
        do.assertEqual(1, do.countOfAnyObjectInnerNav("section"), "Count is not 1 in InnerNav.") 

        # **** Test making person object relevant and verify its effect **************************
        do.navigateToObjectWithSearch(titlePol, "Regulation")
        
        # Before making it relevant
        do.navigateToInnerNavSection("Person")
        do.assertEqual(0, do.countOfAnyObjectInWidget("person"), "Count is not 0 in Widget.")
        do.assertEqual(0, do.countOfAnyObjectInnerNav("person"), "Count is not 0 in InnerNav.")
        
        do.navigateToInnerNavSection("Section")
        do.expandItemWidget("Section", titleSec)  # expand the item so that "+ Section" link is displayed
        do._searchObjectIn3rdLevelAndClickOnIt(titleMkt, True)
        do.expandWidget4thTier(titleMkt, True)

        # Verification: you now see person object from Regulation page
        do.navigateToInnerNavSection("Person")
        do.assertEqual(1, do.countOfAnyObjectInWidget("person"), "Count is not 1 in Widget.")
        do.assertEqual(1, do.countOfAnyObjectInnerNav("person"), "Count is not 1 in InnerNav.")

        # Verification: you don't see person object from Program page
        # 1 because the creator is automatically mapped to the program
        do.navigateToObjectWithSearch(titlePrgm, "Program")
        do.navigateToInnerNavSection("Person")
        do.assertEqual(1, do.countOfAnyObjectInWidget("person"), "Count is not 1 in Widget.")
        do.assertEqual(1, do.countOfAnyObjectInnerNav("person"), "Count is not 1 in InnerNav.")  

        # Verification: regulation object appears in the widget on People page
        do.navigateToObjectWithSearch(titleMkt, "Person")
        do.navigateToInnerNavSection("regulation")
        
        title_fr_widget = do.getTitleFromWidgetList(1, "Person")
        do.assertEqual(titlePol, title_fr_widget, "Titles do match.")