Example #1
0
    def testDeleteObjects(self):
        self.testname="TestDeleteObjects"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util)
        do.login()
        for section in ["Regulation",
                        "Objective",
                        "Program",                        
                        "Contract",
                        "Policy",
                        "Control",
                        "System",
                        "Process",
                        "Data",
                        "Product",
                        "Project",
                        "Facility",
                        "Market",
                        "Group"
                           ]:
            print "Starting Deletion of Objects for " + section
            deleted_objects=0
            do.ensureLHNSectionExpanded(section)
            do.checkMyWorkBox()
            
            object_left_nav_section_object_link = element.left_nav_expand_object_section_link.replace("OBJECT", section)
            
            # enter term to search
            util.inputTextIntoField("Auto", element.left_nav_search_input_textfield)
            util.pressEnterKey(element.left_nav_search_input_textfield)
            
            left_nav_first_link = element.left_nav_first_object_link_in_the_section.replace("SECTION",section)
            util.waitForElementToBePresent(left_nav_first_link)
            lef_nav_objects_for_deletion_in_section = element.left_nav_objects_candidate_for_deletion.replace("SECTION",section )
            number_of_auto_objects = do.countOfAnyObjectLHS(section)
                
            deleted_objects = number_of_auto_objects - 2     # leave 2 behind                        

            while (deleted_objects > 0):
                            
                do.navigateToObjectAndOpenObjectEditWindow(section,lef_nav_objects_for_deletion_in_section, refresh_page=False)
                do.deleteObject()
                deleted_objects = deleted_objects - 1 #LHN collapse after this
                
                do.showLHMenu(True) # reopen it
            
                object_left_nav_section_object_link = element.left_nav_expand_object_section_link.replace("OBJECT", section)
                left_nav_first_link = element.left_nav_first_object_link_in_the_section.replace("SECTION",section)
                util.waitForElementToBePresent(left_nav_first_link)
                lef_nav_objects_for_deletion_in_section = element.left_nav_objects_candidate_for_deletion.replace("SECTION",section )
                
            print "Finished deletion of objects for " + section + ". " + str(deleted_objects) + " object is left to be deleted."
    def testMyWorkPageGeneral(self):
        self.testname="TestMyWorkPageGeneral"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()

        item_input = ['Program', 'Workflow', 'Audit', 'Regulation', 'Policy', 'Standard', 'Contract', 'Clause', 'Section', \
                     'Objective', 'Control', 'Person', 
                     'OrgGroup', 'Vendor', 'System', 'Process', 'DataAsset', 'Product', \
                     'Project', 'Facility', 'Market']


        # open menu
        do.showLHMenu(True)

        # All and my object radio buttons exist?
        do.assertTrue(do.isMyObjectsOnlyPresent(), "My objects only radio button does not exist")
        do.assertTrue(do.isMyObjectsOnlyChecked(), "My objects only is not checked by default")
        
        # get counts for each type of object
        my_list = []
        for object in item_input:
            count_my = do.countOfAnyObjectLHS(object)
            my_list.append(count_my)

        
        do.assertTrue(do.isAllObjectsPresent(), "All objects radio button does not exist")        
        do.assertFalse(do.isAllObjectsChecked(), "All objects is checked by default which is wrong")
        do.uncheckMyWorkBox() # select all radio
          
        # program, workflows, audits with count in the parenthesis should update and should be different than in the above
        # get counts for each type of object
        all_list = []
        for object in item_input:
            count_all = do.countOfAnyObjectLHS(object)
            all_list.append(count_all)
        
        # counts are not updating; it's likely that there is a difference

        count_updated = False
        total_items = len(item_input)
        for object_count in my_list:
            my_count = my_list.pop()
            all_count = all_list.pop()
            total_items = total_items - 1
            
            if not my_count == all_count:
                count_updated = True
                break # good, it updates
            else:
                if total_items == 0:
                    do.assertTrue(count_updated, "Count of objects do not update.  Error.")
                    
            
        
        # verify that objects created by different users show up; repeat for all different object type
        # PRE-REQUISITES:  There are at least 2 objects created by 2 different users for each object type
        print ("WARNING !!!")
        print ("PRE-REQUISITES:  There are at least 2 objects created by 2 different users for each object type")
        for object in item_input:
            do.verifyAllUsersObjectsShown(object)
        
         
        # verify to each items in the LHS exist and labels are correct
        expected   = ['Programs', 'Workflows', 'Audits', 'Regulations', 'Policies', 'Standards', 'Contracts', 'Clauses', 'Sections', \
                     'Objectives', 'Controls', 'People', 
                     'Org Groups', 'Vendors', 'Systems', 'Processes', 'Data Assets', 'Products', \
                     'Projects', 'Facilities', 'Markets']
         
        dictionary = dict(zip(item_input, expected))
        for object in item_input:
            raw = do.getItemLabelInLHS(object)
             
            if object == 'OrgGroup' or \
               object == 'DataAsset':
                Nth = 2
            else:
                Nth = 1
             
            filtered = do.getTextUpToNthSpace(raw, Nth)
            expected_text = dictionary.get(object)
            do.assertTrue(do.compareText(filtered, expected_text), "Mismatch text for object: " + filtered)
        
        # add help content and verify
        do.addHelpTitleContent("Help Me", "I will help you.")
        do.clickHelpTopRightCorner()
        do.assertEqual(do.getHelpTitle(), "Help Me", "Fail to get Help title.")
        #do.assertEqual(do.getHelpContent(), "I will help you.", "Fail to get Help content.")
        do.clickHelpDone()
        
        # click help icon, then click outside of modal
        do.clickHelpIcon()
        do.clickMyTasksIcon()