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

        email = config.reader1
        reader = config.reader2
        password = config.same_password
        title = "Auto_Private_" + do.getTimeId() + str(do.getRandomNumber())

        do.createObject("Program", title, "checked")
        do.verifyObjectIsCreatedinLHN("Program", title)
        do.assertEqual(1, do.countOfAnyObjectLHS("Program"), "Expect count to be 1 but don't see it.")

        # now log out and then log in with the new account and try to create a program
        do.selectMenuInTopRight("Logout")
          
        # Refresh the page
        do.refresh()
          
        # Log in with new user
        do.login(reader, password)
        print "Log in as : " + do.whoAmI()
        do.uncheckMyWorkBox()
        
        try:
            do.verifyObjectIsCreatedinLHN("Program", title)
        except:
            do.assertEqual(0, do.countOfAnyObjectLHS("Program"), "Expect count to be 0 but don't see it.")
            print "Good...private program should not be visible to reader role unless permitted."
    def testFourLevelsMapping(self):
        self.testname="TestFourLevelsMapping"
        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->Regulation->Section->Object
        titlePol = do.getUniqueString("policy")
        titlePrgm = do.getUniqueString("program")
        titleSec = do.getUniqueString("section")
        titleMkt = do.getUniqueString("policy")

        do.createObject("Policy", titlePol)
        do.createObject("Program", titlePrgm)
        do.mapAObjectWidget("Policy", titlePol)
        
        do.createObject("Market", titleMkt)         
        do.createObject("Section", titleSec)
        do.mapAObjectWidget("Market", titleMkt)
                  
        
        do.mapAObjectWidget("Section", titleSec)
    def testMapRegulationToSystem(self):
        self.testname="TestMapRegulationToSystem"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()

        titleReg = do.getUniqueString("regulation")
        titleSys = do.getUniqueString("system")
        
        do.createObject("Regulation", titleReg)
        do.createObject("System", titleSys)       
        do.mapAObjectLHN("Regulation", titleReg)
    def testCreatePersonProgramCreatorLogInOut(self):
        self.testname="TestCreatePersonProgramCreatorLogInOut"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()
 
        aEmail = "auto_email_" + str(do.getRandomNumber(65535)) + "@gmail.com"
        aName = do.getUniqueString("name")
        aCompany = do.getUniqueString("company")
    
        do.selectMenuInTopRight("Admin Dashboard")
        do.selectMenuItemInnerNavDashBoard("People") 
        do.addPersonInAdminDB(aName, aEmail, aCompany)
        self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.")
    
            
        # edit person authorization
        do.selectMenuItemInnerNavDashBoard("People") # on the roles selection      
        do.clickOnEditAuthorization(aName)
        do.assignUserRole("ProgramCreator")
            
        # now log out and then log in with the new account and try to create a program
        oldEmail = "*****@*****.**"
        oldName = "Example User"
        absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py"
        do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath)
        do.selectMenuInTopRight("Logout")
            
        # Refresh the page
        do.refresh()
            
        # Log in with new user
        do.login()
        print "Log in as : " + do.whoAmI()
        
        object_list = ["Program", "Workflow", "Audit", "Regulation", "Policy", "Standard", "Contract", "Clause", 
                       "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset",
                       "Product", "Project", "Facility", "Market"]
        
        for object in object_list:
            
            # cannot create audit; it requires other non-system wide role
            if object == "Audit":          
                do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object))          
            else:
                do.assertTrue(do.doesCreateNewExist(object), "Create New button does not exist for " + str(object))
        
        # should be able to create a program object
        last_created_object_link = do.createObject("Program")
        object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip()
        self.assertTrue(do.partialMatch("program-auto-test", object_name), "Fail to match program name.")
        
        # Restore old login information
        do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath)
        do.selectMenuInTopRight("Logout")   
    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 testMapSystemToPeople(self):
        self.testname="TestMapSystemToPeople"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()

        aEmail = "auto_email_" + str(do.getRandomNumber()) + "@gmail.com"
        aName = do.getUniqueString("name")
        aCompany = do.getUniqueString("company")
        
        titleSys = do.getUniqueString("system")        
        do.createObject("System", titleSys)
        
        do.createPersonLHN(aName, aEmail, aCompany)
        do.mapAObjectLHN("System", titleSys)
 def testProgramCreate(self):
     self.testname="TestProgramCreate"
     self.setup()
     util = WebdriverUtilities()
     util.setDriver(self.driver)
     element = Elements()
     do = Helpers(self)
     do.setUtils(util)
     do.login()
     last_created_object_link =do.createObject("Program")
     do.navigateToObjectAndOpenObjectEditWindow("Program",last_created_object_link)
     do.deleteObject()
 def testSystemCreate(self):
     self.testname="TestSystemCreate"
     self.setup()
     util = WebdriverUtilities()
     util.setDriver(self.driver)
     do = Helpers(self)
     do.setUtils(util)
     do.login()
     last_created_object_link =do.createObject("System")
     #object_name = str(util.getTextFromXpathString(last_created_object_link)).strip()
     do.navigateToObjectAndOpenObjectEditWindow("System",last_created_object_link)
     do.deleteObject()
Exemple #9
0
    def testEventLog(self):
        self.testname="TestEventLog"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util)
        do.login()

      # CREATE PROGRAM
        program_name = "Program_created_from_LHN"  + do.getTimeId()
        object_list = ["Regulation", "Contract", "Policy", "Standard"]
              
        last_created_object_link = do.createObject("Program", program_name)
      
        # MAP SOME OBJECTS
        for obj in object_list: 
            do.mapAObjectLHN(obj, program_name)      
              
        #do.selectInnerTabWhichAlreadyPresent("info")  
        do.selectInnerNavTab("info")      
        do.openObjectEditWindow()
        do.deleteObject()
                    
        do.selectMenuInTopRight("Admin Dashboard")
        do.selectMenuItemInnerNavDashBoard("Events")
            
        # when delete an object that has mapping, it automatically unmap and then delete
        self.assertTrue(do.verifyInfoInEventLogTable("unmapped from", 1), "Cannot find 'unmapped from Program' in the Event Log table.")
           
        # 4 times
        # 4 lines of "mapped to" because there are 4 mappings from the top
        self.assertTrue(do.verifyInfoInEventLogTable("mapped to", 2), "Cannot find 'map to:row2' in the Event Log table.")
        self.assertTrue(do.verifyInfoInEventLogTable("mapped to", 3), "Cannot find 'map to:row3' in the Event Log table.")
        self.assertTrue(do.verifyInfoInEventLogTable("mapped to", 4), "Cannot find 'map to:row4' in the Event Log table.")
        self.assertTrue(do.verifyInfoInEventLogTable("mapped to", 5), "Cannot find 'map to:row5' in the Event Log table.")
           
        # tests the "by whom" and "when at" fields
        self.assertTrue(do.verifyInfoInEventLogTable("whom", 2), "Cannot find 'whom' in the Event Log table.")
        self.assertTrue(do.verifyInfoInEventLogTable("when", 2), "Cannot find 'when' in the Event Log table.")
           
        # the program created should be logged
        self.assertTrue(do.verifyInfoInEventLogTable(program_name, 6), "Cannot find 'create program' in the Event Log table.")
        
        # verify that Prev and Next buttons work
        self.assertTrue(do.verifyPrevNextOperation(), "Fail verifying Prev and Next buttons.")
        
        
        # CORE-727
        print "CORE-727 is still open which causes this failure."
    def testRelevantStress(self):
        self.testname="TestRelevantStress"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()

        titleContract = do.getUniqueString("contract")
        titleClause = do.getUniqueString("clause")
          
        print "Contract: " + titleContract
        print "Clause: " + titleClause
                       
        # SETUP        
        do.checkMyWorkBox() # show my objects only
        # Make sure we have at least 20 data assets already if not create them
        count = do.countOfAnyObjectLHS("Data")
        diff = 20 - count
        while diff > 0:
            id = do.getRandomNumber()            
            do.createObject("Data", "data_" + str(id))
            diff = diff - 1
            do.delay(5)
           
        # Map 20 data assets to Clause
        do.createObject("Clause", titleClause)   
        expandables = []   
        do.mapAObjectWidget("Data_Asset", "data_", False, expandables, 20)
           
        # Map a clause to contract
        do.createObject("Contract", titleContract)
         
        do.mapAObjectWidget("Clause", titleClause, False, ("Clause"), 1)         
        # expand it

        do.expandItemWidget("Clause", titleClause)
         
        # check the MakeAllRelevant checkbox
        do.makeAllRelevant(True)
        do.delay(120) 
        # switch to Data Asset tab
        do.selectInnerNavTab("data_asset")
        do.assertEqual(20, do.countOfAnyObjectInWidget("data_asset"), "Count is not 20 in Data Asset Widget.")
       
        # just select because it will maintain its expanded mode
        do.selectInnerNavTab("clause")  
        
        do.makeAllRelevant(False)
        do.delay(120) # takes time for the unmapping to complete
        
        # switch to Data Asset tab again
        do.selectInnerNavTab("data_asset")
        
        # if MAKE ALL RELEVANT checkbox is deselected, no data asset tab is shown and thus no count is shown either
        print "Continue to fail until CORE-890 is fixed."
        do.assertEqual(0, do.countOfAnyObjectInWidget("data_asset"), "Count is not 0 in Data Asset Widget.")
    def testVendorMapWidget(self):
        self.testname="TestVendorMapWidget"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util, "Vendor")
        do.login()
        vendor_name = "Vendor for Auto Mapping from Widget" + do.getTimeId()
        last_created_object_link = do.createObject("Vendor", vendor_name)

        for obj in grcobject.vendor_map_to_widget: 
            do.mapAObjectWidget(obj, "")
    def testPolicyMapWidget(self):
        self.testname="TestPolicyMapWidget"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util, "Policy")
        do.login()       
        policy_name = "Policy for Auto Mapping from Widget"  +do.getTimeId()
        last_created_object_link = do.createObject("Policy", policy_name)

        for obj in grcobject.policy_map_to_widget: 
            do.mapAObjectWidget(obj, policy_name, False, ("Section", "Objective", "Control"))
    def testDataAssetMapWidget(self):
        self.testname="TestDataAssetMapWidget"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util, "DataAsset")
        do.login()
        data_asset_name = "DataAsset for Auto Mapping from Widget"  +do.getTimeId()
        last_created_object_link = do.createObject("DataAsset",data_asset_name)

        for obj in grcobject.data_asset_map_to_widget: 
            do.mapAObjectWidget(obj)
    def testProgramMapWidget(self):
        self.testname="TestProgramMapWidget"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util, "Program")
        do.login()       
        program_name = "Program for Auto Mapping from Widget" + do.getTimeId()
        last_created_object_link = do.createObject("Program", program_name)

        for obj in grcobject.program_map_to_widget: 
            do.mapAObjectWidget(obj, "", True, ("Control", "Objective", "System"))
    def testControlMapWidget(self):
        self.testname="TestControlMapWidget"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util, "Control")
        do.login()
        control_name = "Control for Auto Mapping from Widget" + do.getTimeId()
        last_created_object_link = do.createObject("Control", control_name)

        for obj in grcobject.control_map_to_widget: 
            do.mapAObjectWidget(obj)
    def testOrgGroupMapWidget(self):
        self.testname="TestOrgGroupMapWidget"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util, "OrgGroup")
        do.login()
        org_group_name = "OrgGroup for Auto Mapping from Widget"  +do.getTimeId()
        last_created_object_link = do.createObject("OrgGroup",org_group_name)

        for obj in grcobject.org_group_map_to_widget: 
            do.mapAObjectWidget(obj)
    def testAdminDBGeneral(self):
        
        # testrecip@gmail exists in the database
        the_email = '*****@*****.**'
        roles = 9 # nine types of roles
        
        self.testname="TestAdminDBGeneral"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()
        
        do.selectMenuInTopRight("Admin Dashboard")
               
        # verify people table
        do.selectMenuItemInnerNavDashBoard("People")       
        self.assertTrue(do.searchPersonInAdminDB(the_email), "Cannot find it in the People table.")
        people_count = do._countOfObjectsFromAdminDB("people")
        self.assertEquals(1, people_count, "Expect count equals to 1, but it's " + str(people_count))
        
        # verify Roles table
        do.selectMenuItemInnerNavDashBoard("Roles")
        roles_count = do._countOfObjectsFromAdminDB("roles")
        self.assertEquals(roles, roles_count, "Expect count equals to" + str(roles) + ", but it's " + str(roles_count))


        # verify events table
        # There are more than 22 thousands entries so can't count every entries.  Work-around is to verify that it
        # increments by 1 when you create an object for example
        do.selectMenuItemInnerNavDashBoard("Events")
        events_count_before = do._countOfObjectsFromAdminDB("events")
        #events_count_from_label = do._countOfObjectsFromAdminDBLabel("events")
        #self.assertEquals(events_count_before, events_count_from_label, "Events count is not in sync.")
        
        xpath = do.createObject("Contract")
        title = util.getTextFromXpathString(xpath)
        do.selectMenuInTopRight("Admin Dashboard")
        
        do.selectMenuItemInnerNavDashBoard("Events")
        do.delay(20) #events table takes time to load
        events_count_after = do._countOfObjectsFromAdminDB("events")
        
        #self.assertEquals(events_count_before, events_count_from_label, "Events count is not in sync.")                    
        self.assertLess(events_count_before, events_count_after, "Count before=" + str(events_count_before) + "; Count after=" + str(events_count_after))
 def testRegulationEdit(self):
     self.testname="TestRegulationEdit"
     self.setup()
     util = WebdriverUtilities()
     util.setDriver(self.driver)
     element = Elements()
     do = Helpers(self)
     grcobject = GRCObject()
     do.setUtils(util)
     do.login()
     last_created_object_link = do.createObject("Regulation")
     object_name = str(util.getTextFromXpathString(last_created_object_link)).strip()
     do.navigateToObjectAndOpenObjectEditWindow("Regulation",last_created_object_link)
     do.populateObjectInEditWindow( object_name , grcobject.regulation_elements, grcobject.regulation_values)
     do.openObjectEditWindow()
     do.verifyObjectValues(grcobject.regulation_elements, grcobject.regulation_values)
     do.deleteObject()
    def testFacilityMapLHN(self):
        self.testname="TestFacilityMapLHN"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util, "Facility")
        do.login()
        system_name = "Facility for Auto Mapping from LHN"  +do.getTimeId()
        last_created_object_link = do.createObject("Facility", system_name)

        for obj in grcobject.facility_map_to_lhn: 
            do.mapAObjectLHN(obj)
       
        # test unmapping
        for obj in grcobject.facility_map_to_lhn: 
            self.assertTrue(do.unmapAObjectFromWidget(obj))
 def testObjectiveMapLHN(self):
     self.testname="TestObjectiveMapLHN"
     self.setup()
     util = WebdriverUtilities()
     util.setDriver(self.driver)
     element = Elements()
     grcobject = GRCObject()
     do = Helpers(self)
     do.setUtils(util, "Objective")
     do.login()
     program_name = "Objective for Auto Mapping from LHN"  +do.getTimeId()
     last_created_object_link = do.createObject("Objective", program_name)
     for obj in grcobject.objective_map_to_lhn: 
         do.mapAObjectLHN(obj)
         #util.refreshPage()
    
     # test unmapping
     for obj in grcobject.objective_map_to_lhn: 
         self.assertTrue(do.unmapAObjectFromWidget(obj))
 def testObjectMapsToItself(self):
     self.testname="TestObjectMapsToItself"
     self.setup()
     util = WebdriverUtilities()
     util.setDriver(self.driver)
     element = Elements()
     grcobject = GRCObject()
     do = Helpers(self)
     do.setUtils(util, "Contract")
     do.login()
     contract_name = "Contract for Auto Mapping from LHN"  +do.getTimeId()
     
     contract_map_to_lhn2 =  ["Contract", "Program"]
     for obj in grcobject.contract_map_to_lhn2:
         last_created_object_link = do.createObject(obj, contract_name)
         do.mapAObjectLHN(obj)
         #util.refreshPage()
    
     # test unmapping
     for obj in grcobject.contract_map_to_lhn: 
         self.assertTrue(do.unmapAObjectFromWidget(obj))
 def testCreateUpdateDeleteSystem(self):
     self.testname="TestCreateUpdateDeleteSystem"
     self.setup()
     util = WebdriverUtilities()
     util.setDriver(self.driver)
     element = Elements()
     grcobject = GRCObject()
     do = Helpers(self)
     do.setUtils(util)
     myUtil = do.getUtils()
     do.login()
     
     aEmail = "*****@*****.**" #already exists in the database
     
     last_created_object_link = do.createObject("System")
     object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip()
     do.navigateToObjectAndOpenObjectEditWindow("System", last_created_object_link)
     do.populateObjectInEditWindow(object_name , grcobject.system_elements, grcobject.system_values, aEmail)
     do.openObjectEditWindow()
     do.verifyObjectValues(grcobject.system_elements, grcobject.system_values)
     do.deleteObject()
    def test_object_creation(self):

        '''Intialization & Setup'''

        self.testname="CreateObjectTests"     # name the test case
        self.setup()                          # do the setup
        do = Helpers()                        # instantiate Helpers class
        util = WebdriverUtilities()           # instantiate utilities class and pass it to Helper object (can remove complexity by inheritance etc and can use seleniumwrapper)
        util.setDriver(self.driver)
        do.setUtils(util)
        do.login()                            # login into the system


        '''Test case'''

        object_list = ["Regulation"]
        #object_list = ["Program", "Contract","Control","DataAsset","Facility","Market","Objective","OrgGroup","Policy","Process","Product",
        #               "Project","Regulation","System","Standard","Clause"]

        for obj in object_list:
            obj_title = do.createObject(obj)
            title = self.driver.find_element_by_css_selector(".row-fluid.wrap-row:first-child .span6:first-child h3").text
            self.assertEqual(title, obj_title)
 def testCreateObjectsAsSetup(self):
           
     self.testname="TestCreateObjectsAsSetup"
     self.setup()
        
     object_list = ["Contract","Control","DataAsset","Facility","Market","Objective","OrgGroup","Policy","Process","Product","Program",
                         "Project","Regulation","System","Standard","Clause"]
         
     util = WebdriverUtilities()
     util.setDriver(self.driver)
     element = Elements()
     do = Helpers(self)
     do.setUtils(util)
     do.login()
     
     print "First:  Log in as : " + do.whoAmI()    
     for obj in object_list:
         count = 0; #initalize to 0
         currentCount = do.countOfAnyObjectLHS(obj)
         if currentCount < 2:
             count = 2 - currentCount;
             
         while count > 0:
             do.createObject(obj)
             count = count - 1
             
     # now log out and then log in with the new account and try to create a program
     do.selectMenuInTopRight("Logout")
        
     # Refresh the page
     do.refresh()
        
     # Log in with new user and create objects
     # This support other tests scripts checking for objects created by different users, and also object counts update
     do.login(config.creator2, config.same_password)
     print "Second:  Log in as : " + do.whoAmI()
     for obj in object_list:
         do.createObject(obj)
     
     # just create one more to test that contract count differ between "all objects" and "my objects"
     do.createObject("Contract")     
    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 testCreatePersonAuthorizationLogInOut(self):
        self.testname="TestCreatePersonAuthorizationLogInOut"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()      

        aEmail = "*****@*****.**"
        aName = do.getUniqueString("name")
        aCompany = do.getUniqueString("company")
        role = "ProgramCreator"
  
        do.selectMenuInTopRight("Admin Dashboard")
         
        # verify people tab
        do.selectMenuItemInnerNavDashBoard("People")
         
        # SETUP: if that email is already used change it to something else
        do.zeroizeThePersonEmail(aEmail)
           
        # you can add a person 
        do.addPersonInAdminDB(aName, aEmail, aCompany)
           
        # the Next and PREVIOUS page buttons work
        self.assertTrue(do.verifyPrevNextOperation("people"), "Fail verifying Prev and Next buttons.")
          
        # search or filter works
        self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.")
           
        # edit person authorization    
        do.clickOnEditAuthorization(aName)
        do.assignUserRole(role)
        
        # at this point, 2nd tier is expanded and it's the only row displayed...
        do.verifyPersonInfoOnSecondTier(aName, aEmail, aCompany, role)

        if 'local' not in config.url:
            do.selectMenuInTopRight("Logout")
            do.refresh()
            do.login(aEmail, config.password)
            self.assertEqual(aEmail, do.whoAmI(), "Expect: " + aEmail + ", but see: " + do.whoAmI())
            
        # I can test login with the new user locally but not on on grc-test.appspot.com because it requires actual email
        # and that email has to be unique.  I can't automatically create new fake email account with google that's fraud            
        else:
            oldEmail = "*****@*****.**"
            oldName = "Example User"
            absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py"
            do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath)            
            
            # now log out and then log in with the new account and try to create a program
            do.selectMenuInTopRight("Logout")
            
            # Refresh the page
            do.refresh()
              
            # Log back in
            do.login()
            print "Log in as : " + do.whoAmI()
            last_created_object_link = do.createObject("Program")
            object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip()
            self.assertTrue(do.partialMatch("program-auto-test", object_name), "Fail to match program name.")
            self.assertEqual(do.whoAmI(), aEmail, "Mismatched. I am: " + do.whoAmI() + ", " + "aEmail: " + aEmail)
            do.selectMenuInTopRight("Logout") 
     
            # Restore old login information
            do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath)
    def testCreatePersonObjectEditorLogInOut(self):
        self.testname="TestCreatePersonObjectEditorLogInOut"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()

        # ***************************** run this block of codes if run locally *****************************
        if "localhost" in config.url:
            print "Executing the block of codes locally ..."
            aEmail = "auto_email_" + str(do.getRandomNumber(65535)) + "@gmail.com"
            aName = do.getUniqueString("name")
            aCompany = do.getUniqueString("company")
       
            do.selectMenuInTopRight("Admin Dashboard")
            do.selectMenuItemInnerNavDashBoard("People") 
            do.addPersonInAdminDB(aName, aEmail, aCompany)
            self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.")
       
               
            # edit person authorization
            do.selectMenuItemInnerNavDashBoard("People") # on the roles selection      
            do.clickOnEditAuthorization(aName)
            do.assignUserRole("ObjectEditor")
               
            # now log out and then log in with the new account and try to create a program
            oldEmail = "Example user"
            oldName = "*****@*****.**"
            absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py"
            do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath)
            do.selectMenuInTopRight("Logout")
               
            # Refresh the page
            do.refresh()
               
            # Log in with new user
            do.login()
            print "Log in as : " + do.whoAmI()
            
            object_list = ["Workflow", "Vendor", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section",
                           "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset",
                           "Product", "Project", "Facility", "Market", "Program", "Audit"]
            
            # since it's an object editor role, the Create New button won't show for certain types
            for object in object_list:
                
                if object=="Program" or object=="Audit":
                    do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object))
                else:
                    do.assertTrue(do.doesCreateNewExist(object), "Create New button does not exist for " + str(object))
            
            # should be able to create an object that is not Program or Audit
            last_created_object_link = do.createObject("Contract")
            object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip()
            self.assertTrue(do.partialMatch("contract-auto-test", object_name), "Fail to match contract name.")
            
            # Restore old login information
            do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath)
            do.selectMenuInTopRight("Logout")  
        #   ******************* execute this else block of codes if not run locally *******************
        else: 
            print "Executing the block of codes for non-local ..."
            aEmail = config.editor2
            aName = do.getUniqueString("name")
            aCompany = do.getUniqueString("company")
       
            do.selectMenuInTopRight("Admin Dashboard")
            do.selectMenuItemInnerNavDashBoard("People") 
            do.addPersonInAdminDB(aName, aEmail, aCompany)
            self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.")
                     
            # edit person authorization
            do.selectMenuItemInnerNavDashBoard("People") # on the roles selection      
            do.clickOnEditAuthorization(aName)
            do.assignUserRole("ObjectEditor")
               
            # now log out and then log in with the new account and try to create a program
            do.selectMenuInTopRight("Logout")
               
            # Refresh the page
            do.refresh()
               
            # Log in with new user
            do.login(aEmail, config.password)
            print "Log in as : " + do.whoAmI()
            
            object_list = ["Workflow", "Vendor", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section",
                           "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset",
                           "Product", "Project", "Facility", "Market", "Program", "Audit"]
            
            # since it's an object editor role, the Create New button won't show for certain types
            
            for object in object_list:
                
                do.ensureLHNSectionExpanded(object)
                
                if object=="Program" or object=="Audit":
                    do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object))
                else:
                    do.assertTrue(do.doesCreateNewExist(object), "Create New button does not exist for " + str(object))
            
            # should be able to create an object that is not Program or Audit
            last_created_object_link = do.createObject("Contract")
            object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip()
            self.assertTrue(do.partialMatch("contract-auto-test", object_name), "Fail to match contract name.")
            
            if "localhost" in config.url:
                # Restore old login information
                do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath)
                do.selectMenuInTopRight("Logout")      
    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.")