class Regroup(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.frameElem = frameElement(driver) self.cnEn = cnEncode() self.dptment = Department(driver) u'''左边框点击资源组''' def click_left_regroup(self): time.sleep(2) self.frameElem.from_frame_to_otherFrame("leftFrame") self.getElem.find_element_wait_and_click_EC("id", "url1") u'''点击资源组展开按钮''' def click_regroup_switch(self): time.sleep(2) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "resource_group_1_switch") u'''点击基本操作 parameter: - operation:代表基本操作0代表添加、1代表编辑、2代表上移、3代表下移、4代表删除 - deptname:传入要被操作的部门名称 - regroup:传入要被操作的资源组名称 ''' def regroup_click_basic_operation(self, operation, deptname='no', regroup='no'): time.sleep(2) if deptname != 'no': self.dptment.click_basic_operation_public_method( deptname, "resource_group_", "_switch") if operation == 0: self.dptment.click_basic_operation_public_method( deptname, "addBtn_resource_group_") elif regroup != 'no': if operation == 1: self.dptment.click_basic_operation_public_method( regroup, "resource_group_", "_edit") elif operation == 2: self.dptment.click_basic_operation_public_method( regroup, "toUpBtn_resource_group_") elif operation == 3: self.dptment.click_basic_operation_public_method( regroup, "toDownBtn_resource_group_") elif operation == 4: self.dptment.click_basic_operation_public_method( regroup, "resource_group_", "_remove") u'''点击上移、下移按钮校验 parameter: - operation:代表基本操作2代表上移、3代表下移 - deptname:传入要被操作的部门名称 - regroup:传入要被操作的资源组名称 ''' def regroup_click_up_down_check(self, operation, deptname='no', regroup='no'): if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method( deptname, "resource_group_", "_switch") self.frameElem.from_frame_to_otherFrame("rigthFrame") #获取所有a标签对象 elems = self.driver.find_elements_by_tag_name("a") for elem in elems: elemtext = elem.get_attribute("title") elemid = elem.get_attribute("id") #判断传入要被操作的资源组和获取的文本是否相等 if regroup == elemtext: self.getElem.find_element_wait_and_click("id", elemid) #点击上移按钮 if operation == 2: #移动次数 locates = range(self.regroup_return_locate_line(regroup)) self.dptment.move_down_check(elemid, locates, "toUpBtn_resource_group_") #点击下移按钮 elif operation == 3: locates = range(self.return_regroup_all_line() - self.regroup_return_locate_line(regroup)) self.dptment.move_down_check(elemid, locates, "toDownBtn_resource_group_") break u'''返回在资源组树中位于第几行 parameter: - regroup:传入要被操作的资源组 ''' def regroup_return_locate_line(self, regroup): self.frameElem.from_frame_to_otherFrame("rigthFrame") elems = self.driver.find_elements_by_tag_name("a") #位于第几行 locate = 0 for elem in elems: elemid = elem.get_attribute("id") elemtext = elem.get_attribute("title") selemid = self.cnEn.cnCode(elemid) sapnid = "resource_group_" + filter(str.isdigit, selemid) + "_ico" spanelem = self.getElem.find_element_with_wait_EC("id", sapnid) spanclass = spanelem.get_attribute("class") if spanclass == "button icozy_ico_docu": locate += 1 if regroup == elemtext: return locate u'''返回在资源组总共几行''' def return_regroup_all_line(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") elems = self.driver.find_elements_by_tag_name("a") #总共几行 locate = 0 for elem in elems: elemid = elem.get_attribute("id") selemid = self.cnEn.cnCode(elemid) sapnid = "resource_group_" + filter(str.isdigit, selemid) + "_ico" spanelem = self.getElem.find_element_with_wait_EC("id", sapnid) spanclass = spanelem.get_attribute("class") if spanclass == "button icozy_ico_docu": locate += 1 return locate + 1 u'''点击资源组添加资源按钮 parameter: - regroup:传入要被操作的资源组名称 - deptname:传入要被操作的部门名称 ''' def click_regroup_add_resouce(self, regroup, deptname='no'): time.sleep(2) self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method( deptname, "resource_group_", "_switch") #选中资源组 self.dptment.click_basic_operation_public_method( regroup, "resource_group_", "_span") self.getElem.find_element_wait_and_click_EC("id", "add_Resource") u'''点击资源组批量删除资源按钮 parameter: - regroup:传入要被操作的资源组名称 - deptname:传入要被操作的部门名称 ''' def click_regroup_bulk_resouce(self, regroup, deptname='no'): time.sleep(2) self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method( deptname, "resource_group_", "_switch") #选中资源组 self.dptment.click_basic_operation_public_method( regroup, "resource_group_", "_span") self.check_delect_all() self.getElem.find_element_wait_and_click_EC("id", "delete_Resource") u'''点击资源组删除资源按钮 parameter: - regroup:传入要被操作的资源组名称 - rename:资源名称 - deptname:传入要被操作的部门名称 ''' def click_regroup_del_resouce(self, regroup, rename, deptname='no'): time.sleep(2) self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method( deptname, "resource_group_", "_switch") #选中资源组 self.dptment.click_basic_operation_public_method( regroup, "resource_group_", "_span") #获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "ta") #获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") #位于第几行 line = 0 #循环所有tr for trelem in trelems: line += 1 #找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") #获取td[2]的文本 tdtext = tds[2].text if tdtext == rename: xpath = "/html/body/div/div[2]/div[7]/div/table/tbody/tr[" + str( line) + "]/td[6]/input" time.sleep(2) self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''勾选资源组全选删除框''' def check_delect_all(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "delect_all") u'''点击资源组检索按钮''' def click_regroup_query(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "query_Resource") u'''点击资源组重置按钮''' def click_regroup_reset(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "resetting") u'''资源组页面填写资源名称或IP parameter: - renameorip:资源名称或IP ''' def set_rename_ip(self, renameorip): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear('id', "txtfortResourceAccountOrIp") self.getElem.find_element_wait_and_sendkeys( 'id', "txtfortResourceAccountOrIp", renameorip) u'''点击资源组添加资源的检索按钮''' def click_regroup_add_resouce_query(self): time.sleep(2) self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "quick_Resource") u'''点击资源组添加资源的重置按钮''' def click_regroup_add_resouce_reset(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "resetting") u'''添加资源页面填写资源名称 parameter: - rename:资源名称 ''' def set_rename(self, rename): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear('id', "fort_resource_name") self.getElem.find_element_wait_and_sendkeys('id', "fort_resource_name", rename) u'''添加资源页面填写资源ip parameter: - ipdress:资源ip ''' def set_ip(self, ipdress): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear('id', "fort_resource_ip") self.getElem.find_element_wait_and_sendkeys('id', "fort_resource_ip", ipdress) u'''点击资源部门展开按钮''' def click_resource_depart_switch(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "user_tree_1_switch") u'''勾选部门框 parameter: - deptname:传入要被勾选的部门名称 ''' def check_depart(self, deptname): self.click_resource_depart_switch() time.sleep(2) self.frameElem.from_frame_to_otherFrame("artIframe") self.click_public_method(deptname, "user_tree_", "_check") u'''勾选资源框或者部门框 parameter: - rename:资源名称或者部门名称 ''' def check_one_resource(self, rename): self.frameElem.from_frame_to_otherFrame("artIframe") #获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "user_table") #获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") #位于第几行 line = 0 #循环所有tr for trelem in trelems: line += 1 #找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") #获取td[2]的文本 tdtext = tds[1].text if tdtext == rename: xpath = "/html/body/div[3]/div[2]/table/tbody/tr[" + str( line) + "]/td[1]/li/input" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''勾选全部资源框或者部门框''' def check_all_resource(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "user_check_all") u'''点击资源确定按钮''' def click_resource_okbutton(self): self.frameElem.switch_to_content() self.getElem.find_element_wait_and_click_EC("id", "okButton") u'''点击公共方法 parameter: - name:传入要被操作的名称 - first:id的前半段字符 - end:id的后半段字符,可以不进行填写 ''' def click_public_method(self, name, first, end='no'): self.frameElem.from_frame_to_otherFrame("artIframe") #获取所有a标签的对象 elems = self.driver.find_elements_by_tag_name("a") for elem in elems: elemtext = elem.get_attribute("title") elemid = elem.get_attribute("id") selemid = self.cnEn.cnCode(elemid) if name == elemtext: self.getElem.find_element_wait_and_click("id", elemid) if end != 'no': buttonid = first + filter(str.isdigit, selemid) + end else: buttonid = first + filter(str.isdigit, selemid) self.getElem.find_element_wait_and_click("id", buttonid) break
class Regroup(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.frameElem = frameElement(driver) self.cnEn = cnEncode() self.dptment = Department(driver) u'''左边框点击资源组''' def click_left_regroup(self): self.frameElem.from_frame_to_otherFrame("leftFrame") self.getElem.find_element_wait_and_click_EC("id", "url0") u'''点击资源组展开按钮''' def click_regroup_switch(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "resource_group_1_switch") u'''点击基本操作 parameter: - operation:代表基本操作0代表添加、1代表编辑、2代表上移、3代表下移、4代表删除 - deptname:传入要被操作的部门名称 - regroup:传入要被操作的资源组名称 ''' def regroup_click_basic_operation(self, operation, deptname='no', regroup='no'): if deptname != 'no': self.dptment.click_basic_operation_public_method(deptname, "resource_group_", "_switch") if operation == 0: self.dptment.click_basic_operation_public_method(deptname, "addBtn_resource_group_") elif regroup != 'no': if operation == 1: self.dptment.click_basic_operation_public_method(regroup, "resource_group_", "_edit") elif operation == 2: self.dptment.click_basic_operation_public_method(regroup, "toUpBtn_resource_group_") elif operation == 3: self.dptment.click_basic_operation_public_method(regroup, "toDownBtn_resource_group_") elif operation == 4: self.dptment.click_basic_operation_public_method(regroup, "resource_group_", "_remove") u'''点击上移、下移按钮校验 parameter: - operation:代表基本操作2代表上移、3代表下移 - deptname:传入要被操作的部门名称 - regroup:传入要被操作的资源组名称 ''' def regroup_click_up_down_check(self, operation, deptname='no', regroup='no'): if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method(deptname, "resource_group_", "_switch") self.frameElem.from_frame_to_otherFrame("rigthFrame") #获取所有a标签对象 elems = self.driver.find_elements_by_tag_name("a") for elem in elems: elemtext = elem.get_attribute("title") elemid = elem.get_attribute("id") #判断传入要被操作的资源组和获取的文本是否相等 if regroup == elemtext: self.getElem.find_element_wait_and_click("id", elemid) #点击上移按钮 if operation == 2: #移动次数 locates = range(self.regroup_return_locate_line(regroup)) self.dptment.move_down_check(elemid, locates, "toUpBtn_resource_group_") #点击下移按钮 elif operation == 3: locates = range(self.return_regroup_all_line() - self.regroup_return_locate_line(regroup)) self.dptment.move_down_check(elemid, locates, "toDownBtn_resource_group_") break u'''返回在资源组树中位于第几行 parameter: - regroup:传入要被操作的资源组 ''' def regroup_return_locate_line(self, regroup): self.frameElem.from_frame_to_otherFrame("rigthFrame") elems = self.driver.find_elements_by_tag_name("a") #位于第几行 locate = 0 for elem in elems: elemid = elem.get_attribute("id") elemtext = elem.get_attribute("title") selemid = self.cnEn.cnCode(elemid) sapnid = "resource_group_" + filter(str.isdigit, selemid) + "_ico" spanelem = self.getElem.find_element_with_wait_EC("id", sapnid) spanclass = spanelem.get_attribute("class") if spanclass == "button icozy_ico_docu": locate += 1 if regroup == elemtext: return locate u'''返回在资源组总共几行''' def return_regroup_all_line(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") elems = self.driver.find_elements_by_tag_name("a") #总共几行 locate = 0 for elem in elems: elemid = elem.get_attribute("id") selemid = self.cnEn.cnCode(elemid) sapnid = "resource_group_" + filter(str.isdigit, selemid) + "_ico" spanelem = self.getElem.find_element_with_wait_EC("id", sapnid) spanclass = spanelem.get_attribute("class") if spanclass == "button icozy_ico_docu": locate += 1 return locate + 1 u'''点击资源组添加资源按钮 parameter: - regroup:传入要被操作的资源组名称 - deptname:传入要被操作的部门名称 ''' def click_regroup_add_resouce(self, regroup, deptname='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method(deptname, "resource_group_", "_switch") #选中资源组 self.dptment.click_basic_operation_public_method(regroup, "resource_group_", "_span") self.getElem.find_element_wait_and_click_EC("id", "add_Resource") u'''点击资源组批量删除资源按钮 parameter: - regroup:传入要被操作的资源组名称 - deptname:传入要被操作的部门名称 ''' def click_regroup_bulk_resouce(self, regroup, deptname='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method(deptname, "resource_group_", "_switch") #选中资源组 self.dptment.click_basic_operation_public_method(regroup, "resource_group_", "_span") self.check_delect_all() self.getElem.find_element_wait_and_click_EC("id", "delete_Resource") u'''点击资源组删除资源按钮 parameter: - regroup:传入要被操作的资源组名称 - rename:资源名称 - deptname:传入要被操作的部门名称 ''' def click_regroup_del_resouce(self, regroup, rename, deptname='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method(deptname, "resource_group_", "_switch") #选中资源组 self.dptment.click_basic_operation_public_method(regroup, "resource_group_", "_span") #获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "ta") #获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") #位于第几行 line = 0 #循环所有tr for trelem in trelems: line += 1 #找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") #获取td[2]的文本 tdtext = tds[2].text if tdtext == rename: xpath = "/html/body/div/div[2]/div[7]/div/table/tbody/tr[" + str(line) + "]/td[6]/input" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''勾选资源组全选删除框''' def check_delect_all(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "delect_all") u'''点击资源组检索按钮''' def click_regroup_query(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "query_Resource") u'''点击资源组重置按钮''' def click_regroup_reset(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "resetting") u'''资源组页面填写资源名称或IP parameter: - renameorip:资源名称或IP ''' def set_rename_ip(self, renameorip): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear('id', "txtfortResourceAccountOrIp") self.getElem.find_element_wait_and_sendkeys('id', "txtfortResourceAccountOrIp", renameorip) u'''点击资源组添加资源的检索按钮''' def click_regroup_add_resouce_query(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "quick_Resource") u'''点击资源组添加资源的重置按钮''' def click_regroup_add_resouce_reset(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "resetting") u'''添加资源页面填写资源名称 parameter: - rename:资源名称 ''' def set_rename(self, rename): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear('id', "fort_resource_name") self.getElem.find_element_wait_and_sendkeys('id', "fort_resource_name", rename) u'''添加资源页面填写资源ip parameter: - ipdress:资源ip ''' def set_ip(self, ipdress): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear('id', "fort_resource_ip") self.getElem.find_element_wait_and_sendkeys('id', "fort_resource_ip", ipdress) u'''点击资源部门展开按钮''' def click_resource_depart_switch(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "user_tree_1_switch") u'''勾选部门框 parameter: - deptname:传入要被勾选的部门名称 ''' def check_depart(self, deptname): self.click_resource_depart_switch() self.frameElem.from_frame_to_otherFrame("artIframe") self.click_public_method(deptname, "user_tree_", "_check") u'''勾选资源框或者部门框 parameter: - rename:资源名称或者部门名称 ''' def check_one_resource(self, rename): self.frameElem.from_frame_to_otherFrame("artIframe") #获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "user_table") #获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") #位于第几行 line = 0 #循环所有tr for trelem in trelems: line += 1 #找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") #获取td[2]的文本 tdtext = tds[1].text if tdtext == rename: xpath = "/html/body/div[3]/div[2]/table/tbody/tr[" + str(line) + "]/td[1]/li/input" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''勾选全部资源框或者部门框''' def check_all_resource(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "user_check_all") u'''点击资源确定按钮''' def click_resource_okbutton(self): self.frameElem.switch_to_content() self.getElem.find_element_wait_and_click_EC("id", "okButton") u'''点击公共方法 parameter: - name:传入要被操作的名称 - first:id的前半段字符 - end:id的后半段字符,可以不进行填写 ''' def click_public_method(self, name, first, end='no'): self.frameElem.from_frame_to_otherFrame("artIframe") #获取所有a标签的对象 elems = self.driver.find_elements_by_tag_name("a") for elem in elems: elemtext = elem.get_attribute("title") elemid = elem.get_attribute("id") selemid = self.cnEn.cnCode(elemid) if name == elemtext: self.getElem.find_element_wait_and_click("id", elemid) if end != 'no': buttonid = first + filter(str.isdigit, selemid) + end else: buttonid = first + filter(str.isdigit, selemid) self.getElem.find_element_wait_and_click("id", buttonid) break
class Usergroup(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.frameElem = frameElement(driver) self.cnEn = cnEncode() self.dptment = Department(driver) self.regroup = Regroup(driver) u'''左边框点击用户组''' def click_left_usergroup(self): self.frameElem.from_frame_to_otherFrame("leftFrame") self.getElem.find_element_wait_and_click_EC("id", "url1") u'''点击用户组展开按钮''' def click_usergroup_switch(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "user_group_1_switch") u'''点击基本操作 parameter: - operation:代表基本操作0代表添加、1代表编辑、2代表上移、3代表下移、4代表删除 - deptname:传入要被操作的部门名称 - usergroup:传入要被操作的用户组名称 ''' def usergroup_click_basic_operation(self, operation, deptname='no', usergroup='no'): if deptname != 'no': self.dptment.click_basic_operation_public_method(deptname, "user_group_", "_switch") if operation == 0: self.dptment.click_basic_operation_public_method(deptname, "addBtn_user_group_") elif usergroup != 'no': if operation == 1: self.dptment.click_basic_operation_public_method(usergroup, "user_group_", "_edit") elif operation == 2: self.dptment.click_basic_operation_public_method(usergroup, "toUpBtn_user_group_") elif operation == 3: self.dptment.click_basic_operation_public_method(usergroup, "toDownBtn_user_group_") elif operation == 4: self.dptment.click_basic_operation_public_method(usergroup, "user_group_", "_remove") u'''点击上移、下移按钮校验 parameter: - operation:代表基本操作2代表上移、3代表下移 - deptname:传入要被操作的部门名称 - usergroup:传入要被操作的用户组名称 ''' def usergroup_click_up_down_check(self, operation, deptname='no', usergroup='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method(deptname, "user_group_", "_switch") #获取所有a标签对象 elems = self.driver.find_elements_by_tag_name("a") for elem in elems: elemtext = elem.get_attribute("title") elemid = elem.get_attribute("id") #判断传入要被操作的资源组和获取的文本是否相等 if usergroup == elemtext: self.getElem.find_element_wait_and_click("id", elemid) #点击上移按钮 if operation == 2: #移动次数 locates = range(self.usergroup_return_locate_line(usergroup)) self.dptment.move_down_check(elemid, locates, "toUpBtn_user_group_") #点击下移按钮 elif operation == 3: locates = range(self.return_usergroup_all_line() - self.usergroup_return_locate_line(usergroup)) self.dptment.move_down_check(elemid, locates, "toDownBtn_user_group_") break u'''返回在用户组树中位于第几行 parameter: - usergroup:传入要被操作的用户组 ''' def usergroup_return_locate_line(self, usergroup): self.frameElem.from_frame_to_otherFrame("rigthFrame") elems = self.driver.find_elements_by_tag_name("a") #位于第几行 locate = 0 for elem in elems: elemid = elem.get_attribute("id") elemtext = elem.get_attribute("title") selemid = self.cnEn.cnCode(elemid) sapnid = "user_group_" + filter(str.isdigit, selemid) + "_ico" spanelem = self.getElem.find_element_with_wait_EC("id", sapnid) spanclass = spanelem.get_attribute("class") if spanclass == "button icoyh_ico_docu": locate += 1 if usergroup == elemtext: return locate u'''返回在用户组总共几行''' def return_usergroup_all_line(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") elems = self.driver.find_elements_by_tag_name("a") #总共几行 locate = 0 for elem in elems: elemid = elem.get_attribute("id") selemid = self.cnEn.cnCode(elemid) sapnid = "user_group_" + filter(str.isdigit, selemid) + "_ico" spanelem = self.getElem.find_element_with_wait_EC("id", sapnid) spanclass = spanelem.get_attribute("class") if spanclass == "button icoyh_ico_docu": locate += 1 return locate + 1 u'''点击用户组添加用户按钮 parameter: - usergroup:传入要被操作的用户组名称 - deptname:传入要被操作的部门名称 ''' def click_usergroup_add_user(self, usergroup, deptname='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method(deptname, "user_group_", "_switch") #选中用户组 self.dptment.click_basic_operation_public_method(usergroup, "user_group_", "_span") self.getElem.find_element_wait_and_click_EC("id", "add_user") u'''点击用户组添加用户的检索按钮''' def click_usergroup_add_user_query(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "quick_user") u'''用户组页面填写用户名称或账号 parameter: - username:用户名称或账号 ''' def set_username(self, username): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear('id', "txtUserNameOrAccount") self.getElem.find_element_wait_and_sendkeys('id', "txtUserNameOrAccount", username) u'''点击用户组检索按钮''' def click_usergroup_query(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "query_user") u'''点击用户组删除用户按钮 parameter: - usergroup:传入要被操作的用户组名称 - username:用户名称 - deptname:传入要被操作的部门名称 ''' def click_usergroup_del_user(self, usergroup, username, deptname='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method(deptname, "user_group_", "_switch") #选中用户组 self.dptment.click_basic_operation_public_method(usergroup, "user_group_", "_span") #获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "ta") #获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") #位于第几行 line = 0 #循环所有tr for trelem in trelems: line += 1 #找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") #获取td[2]的文本 tdtext = tds[2].text if tdtext == username: xpath = "/html/body/div/div[2]/div[7]/div/table/tbody/tr[" + str(line) + "]/td[6]/input" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''点击用户组批量删除用户按钮 parameter: - usergroup:传入要被操作的用户组名称 - deptname:传入要被操作的部门名称 ''' def click_usergroup_bulk_user(self, usergroup, deptname='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method(deptname, "user_group_", "_switch") #选中用户组 self.dptment.click_basic_operation_public_method(usergroup, "user_group_", "_span") self.regroup.check_delect_all() self.getElem.find_element_wait_and_click_EC("id", "delete_all_user")
class testRegroup(object): def __init__(self, driver): self.driver = driver self.log = log() self.testrole = testRole(driver) self.cmf = commonFun(driver) self.frameElem = frameElement(driver) self.regroup = Regroup(driver) self.dptment = Department(driver) u'''获取测试数据 Parameters: - sheetname:sheet名称 return:表格数据 ''' def get_regroup_data(self, sheetname): dataFile = dataFileName() regrPath = dataFile.get_regroup_test_data_url() regrData = dataFile.get_data(regrPath, sheetname) return regrData u'''添加和编辑资源组''' def add_edit_regroup_001(self): #日志开始记录 self.log.log_start("add_edit_regroup") #获取添加资源组测试数据 regrData = self.get_regroup_data("add_edit_regroup") #保存成功的弹出框 regrMsg = self.testrole.popup() self.regroup.click_left_regroup() #无检查点的测试项标识,如果为True说明通过 flag = False #页面弹出框的文本信息 pagetext = u"消息" #点击展开按钮 self.regroup.click_regroup_switch() for dataRow in range(len(regrData)): data = regrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.regroup.regroup_click_basic_operation( int(data[4]), data[2], data[3]) self.dptment.popup_sendkey(data[5]) self.dptment.click_ok_button() time.sleep(3) self.frameElem.switch_to_content() self.dptment.multil_div_check_point( "xpath", regrMsg, data, flag, pagetext) except Exception as e: print("add_edit_regroup fail:" + str(e)) self.log.log_end("add_edit_regroup") u'''上移和下移资源组''' def up_down_regroup_002(self): #日志开始记录 self.log.log_start("up_down_regroup") #获取上移资源组测试数据 regrData = self.get_regroup_data("up_down_regroup") self.regroup.click_left_regroup() #点击展开按钮 self.regroup.click_regroup_switch() for dataRow in range(len(regrData)): data = regrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.regroup.regroup_click_basic_operation( int(data[4]), data[2], data[3]) self.log.log_detail(data[0], True) except Exception as e: print("up_down_regroup fail:" + str(e)) self.log.log_end("up_down_regroup") u'''上移和下移资源组校验''' def up_down_regroup_check_003(self): #日志开始记录 self.log.log_start("up_down_regroup_check") #无检查点的测试项标识,如果为True说明通过 flag = False #获取上移资源组测试数据 regrData = self.get_regroup_data("up_down_regroup") #保存成功的弹出框 regrMsg = self.testrole.popup() self.regroup.click_left_regroup() #点击展开按钮 self.regroup.click_regroup_switch() for dataRow in range(len(regrData)): data = regrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.regroup.regroup_click_up_down_check( int(data[4]), data[2], data[3]) self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", regrMsg, data, flag) except Exception as e: print("up_down_regroup_check fail:" + str(e)) self.log.log_end("up_down_regroup_check") u'''检验添加和编辑资源组''' def check_add_edit_regroup_004(self): #日志开始记录 self.log.log_start("check_add_edit_regroup") #获取检验添加资源组测试数据 regrData = self.get_regroup_data("check_add_edit_regroup") #保存成功的弹出框 regrMsg = self.testrole.popup() #页面弹出框的文本信息 pagetext = u"警告" self.regroup.click_left_regroup() #无检查点的测试项标识,如果为True说明通过 flag = False #点击展开按钮 self.regroup.click_regroup_switch() for dataRow in range(len(regrData)): data = regrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.regroup.regroup_click_basic_operation( int(data[4]), data[2], data[3]) if dataRow != 1 and dataRow != 2: self.dptment.popup_sendkey(data[5]) if dataRow == 2: self.dptment.clear_depart_text() self.dptment.click_ok_button() self.frameElem.switch_to_content() self.dptment.multil_div_check_point( "xpath", regrMsg, data, flag, pagetext) self.driver.implicitly_wait(20) self.frameElem.switch_to_content() self.dptment.click_cancel_button() except Exception as e: print("check_add_edit_regroup fail:" + str(e)) self.log.log_end("check_add_edit_regroup") u'''删除资源组''' def del_regroup_005(self): #日志开始记录 self.log.log_start("del_regroup") #删除的弹出框 regrMsg = self.testrole.popup() #获取删除资源组测试数据 regrData = self.get_regroup_data("del_regroup") self.regroup.click_left_regroup() flag = False #点击展开按钮 self.regroup.click_regroup_switch() for dataRow in range(len(regrData)): data = regrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.regroup.regroup_click_basic_operation( int(data[4]), data[2], data[3]) self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", regrMsg, data, flag) self.frameElem.switch_to_content() self.cmf.click_msg_button(1) except Exception as e: print("del_regroup fail:" + str(e)) self.log.log_end("del_regroup") u'''资源组中添加资源''' def regroup_add_resource_001(self): #日志开始记录 self.log.log_start("regroup_add_resource") #获取添加资源组测试数据 regrData = self.get_regroup_data("regroup_add_resource") #保存成功的弹出框 regrMsg = self.testrole.popup() self.regroup.click_left_regroup() #无检查点的测试项标识,如果为True说明通过 flag = False #点击展开按钮 self.regroup.click_regroup_switch() for dataRow in range(len(regrData)): data = regrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.regroup.click_regroup_add_resouce(data[3], data[2]) self.regroup.check_depart(data[4]) self.regroup.click_regroup_add_resouce_query() self.regroup.check_all_resource() self.regroup.click_resource_okbutton() self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", regrMsg, data, flag) except Exception as e: print("regroup_add_resource fail:" + str(e)) self.log.log_end("regroup_add_resource") u'''资源组中查询资源名称和IP''' def query_regroup_002(self): #日志开始记录 self.log.log_start("query_regroup") self.regroup.click_left_regroup() #点击展开按钮 self.regroup.click_regroup_switch() #获取查询资源组测试数据 regrData = self.get_regroup_data("query_regroup") for dataRow in range(len(regrData)): data = regrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: if dataRow == 1: #选中资源组 self.dptment.click_basic_operation_public_method( data[2], "resource_group_", "_span") self.regroup.click_regroup_reset() else: self.regroup.set_rename_ip(data[3]) self.regroup.click_regroup_query() self.regroup.click_regroup_reset() self.log.log_detail(data[0], True) except Exception as e: print("query_regroup fail:" + str(e)) self.log.log_end("query_regroup") u'''资源组删除资源''' def regroup_del_resouce_003(self): #日志开始记录 self.log.log_start("regroup_del_resouce") #删除的弹出框 regrMsg = self.testrole.popup() #获取删除资源组测试数据 regrData = self.get_regroup_data("regroup_del_resouce") self.regroup.click_left_regroup() flag = False #点击展开按钮 self.regroup.click_regroup_switch() for dataRow in range(len(regrData)): data = regrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.regroup.click_regroup_del_resouce(data[3], data[4]) self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", regrMsg, data, flag) self.frameElem.switch_to_content() self.cmf.click_msg_button(1) except Exception as e: print("regroup_del_resouce fail:" + str(e)) self.log.log_end("regroup_del_resouce") u'''资源组全选删除资源''' def regroup_bulk_resouce_004(self): #日志开始记录 self.log.log_start("regroup_bulk_resouce") #删除的弹出框 regrMsg = self.testrole.popup() #获取删除资源组测试数据 regrData = self.get_regroup_data("regroup_bulk_resouce") self.regroup.click_left_regroup() flag = False #点击展开按钮 self.regroup.click_regroup_switch() for dataRow in range(len(regrData)): data = regrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.regroup.click_regroup_bulk_resouce(data[3]) self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", regrMsg, data, flag) self.frameElem.switch_to_content() self.cmf.click_msg_button(1) except Exception as e: print("regroup_bulk_resouce fail:" + str(e)) self.log.log_end("regroup_bulk_resouce")
class Usergroup(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.frameElem = frameElement(driver) self.cnEn = cnEncode() self.dptment = Department(driver) self.regroup = Regroup(driver) u'''左边框点击用户组''' def click_left_usergroup(self): self.frameElem.from_frame_to_otherFrame("leftFrame") self.getElem.find_element_wait_and_click_EC("id", "url2") u'''点击用户组展开按钮''' def click_usergroup_switch(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "user_group_1_switch") u'''点击基本操作 parameter: - operation:代表基本操作0代表添加、1代表编辑、2代表上移、3代表下移、4代表删除 - deptname:传入要被操作的部门名称 - usergroup:传入要被操作的用户组名称 ''' def usergroup_click_basic_operation(self, operation, deptname='no', usergroup='no'): if deptname != 'no': self.dptment.click_basic_operation_public_method( deptname, "user_group_", "_switch") if operation == 0: self.dptment.click_basic_operation_public_method( deptname, "addBtn_user_group_") elif usergroup != 'no': if operation == 1: self.dptment.click_basic_operation_public_method( usergroup, "user_group_", "_edit") elif operation == 2: self.dptment.click_basic_operation_public_method( usergroup, "toUpBtn_user_group_") elif operation == 3: self.dptment.click_basic_operation_public_method( usergroup, "toDownBtn_user_group_") elif operation == 4: self.dptment.click_basic_operation_public_method( usergroup, "user_group_", "_remove") u'''点击上移、下移按钮校验 parameter: - operation:代表基本操作2代表上移、3代表下移 - deptname:传入要被操作的部门名称 - usergroup:传入要被操作的用户组名称 ''' def usergroup_click_up_down_check(self, operation, deptname='no', usergroup='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method( deptname, "user_group_", "_switch") #获取所有a标签对象 elems = self.driver.find_elements_by_tag_name("a") for elem in elems: elemtext = elem.get_attribute("title") elemid = elem.get_attribute("id") #判断传入要被操作的资源组和获取的文本是否相等 if usergroup == elemtext: self.getElem.find_element_wait_and_click("id", elemid) #点击上移按钮 if operation == 2: #移动次数 locates = range( self.usergroup_return_locate_line(usergroup)) self.dptment.move_down_check(elemid, locates, "toUpBtn_user_group_") #点击下移按钮 elif operation == 3: locates = range( self.return_usergroup_all_line() - self.usergroup_return_locate_line(usergroup)) self.dptment.move_down_check(elemid, locates, "toDownBtn_user_group_") break u'''返回在用户组树中位于第几行 parameter: - usergroup:传入要被操作的用户组 ''' def usergroup_return_locate_line(self, usergroup): self.frameElem.from_frame_to_otherFrame("rigthFrame") elems = self.driver.find_elements_by_tag_name("a") #位于第几行 locate = 0 for elem in elems: elemid = elem.get_attribute("id") elemtext = elem.get_attribute("title") selemid = self.cnEn.cnCode(elemid) sapnid = "user_group_" + filter(str.isdigit, selemid) + "_ico" spanelem = self.getElem.find_element_with_wait_EC("id", sapnid) spanclass = spanelem.get_attribute("class") if spanclass == "button icoyh_ico_docu": locate += 1 if usergroup == elemtext: return locate u'''返回在用户组总共几行''' def return_usergroup_all_line(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") elems = self.driver.find_elements_by_tag_name("a") #总共几行 locate = 0 for elem in elems: elemid = elem.get_attribute("id") selemid = self.cnEn.cnCode(elemid) sapnid = "user_group_" + filter(str.isdigit, selemid) + "_ico" spanelem = self.getElem.find_element_with_wait_EC("id", sapnid) spanclass = spanelem.get_attribute("class") if spanclass == "button icoyh_ico_docu": locate += 1 return locate + 1 u'''点击用户组添加用户按钮 parameter: - usergroup:传入要被操作的用户组名称 - deptname:传入要被操作的部门名称 ''' def click_usergroup_add_user(self, usergroup, deptname='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method( deptname, "user_group_", "_switch") #选中用户组 self.dptment.click_basic_operation_public_method( usergroup, "user_group_", "_span") self.getElem.find_element_wait_and_click_EC("id", "add_user") u'''点击用户组添加用户的检索按钮''' def click_usergroup_add_user_query(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "quick_user") u'''用户组页面填写用户名称或账号 parameter: - username:用户名称或账号 ''' def set_username(self, username): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear('id', "txtUserNameOrAccount") self.getElem.find_element_wait_and_sendkeys('id', "txtUserNameOrAccount", username) u'''点击用户组检索按钮''' def click_usergroup_query(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "query_user") u'''点击用户组删除用户按钮 parameter: - usergroup:传入要被操作的用户组名称 - username:用户名称 - deptname:传入要被操作的部门名称 ''' def click_usergroup_del_user(self, usergroup, username, deptname='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method( deptname, "user_group_", "_switch") #选中用户组 self.dptment.click_basic_operation_public_method( usergroup, "user_group_", "_span") #获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "ta") #获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") #位于第几行 line = 0 #循环所有tr for trelem in trelems: line += 1 #找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") #获取td[2]的文本 tdtext = tds[2].text if tdtext == username: xpath = "/html/body/div/div[2]/div[7]/div/table/tbody/tr[" + str( line) + "]/td[6]/input" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''点击用户组批量删除用户按钮 parameter: - usergroup:传入要被操作的用户组名称 - deptname:传入要被操作的部门名称 ''' def click_usergroup_bulk_user(self, usergroup, deptname='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") if deptname != 'no': #点击要操作部门的展开按钮 self.dptment.click_basic_operation_public_method( deptname, "user_group_", "_switch") #选中用户组 self.dptment.click_basic_operation_public_method( usergroup, "user_group_", "_span") self.regroup.check_delect_all() self.getElem.find_element_wait_and_click_EC("id", "delete_all_user")
class testUsergroup(object): def __init__(self, driver): self.driver = driver self.log = log() self.testrole = testRole(driver) self.cmf = commonFun(driver) self.frameElem = frameElement(driver) self.regroup = Regroup(driver) self.dptment = Department(driver) self.usergroup = Usergroup(driver) u'''获取测试数据 Parameters: - sheetname:sheet名称 return:表格数据 ''' def get_usergroup_data(self, sheetname): dataFile = dataFileName() usergrPath = dataFile.get_usergroup_test_data_url() usergrData = dataFile.get_data(usergrPath, sheetname) return usergrData u'''添加和编辑用户组''' def add_edit_usergroup_001(self): #日志开始记录 self.log.log_start("add_edit_usergroup") #获取添加用户组测试数据 usergrData = self.get_usergroup_data("add_edit_usergroup") #保存成功的弹出框 usergrMsg = self.testrole.popup() self.usergroup.click_left_usergroup() #无检查点的测试项标识,如果为True说明通过 flag = False #页面弹出框的文本信息 pagetext = u"消息" #点击展开按钮 self.usergroup.click_usergroup_switch() for dataRow in range(len(usergrData)): data = usergrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.usergroup.usergroup_click_basic_operation(int(data[4]), data[2], data[3]) self.dptment.popup_sendkey(data[5]) self.dptment.click_ok_button() time.sleep(3) self.frameElem.switch_to_content() self.dptment.multil_div_check_point("xpath", usergrMsg, data, flag, pagetext) except Exception as e: print ("add_edit_usergroup fail:" + str(e)) self.log.log_end("add_edit_usergroup") u'''上移和下移用户组''' def up_down_usergroup_002(self): #日志开始记录 self.log.log_start("up_down_usergroup") #获取上移用户组测试数据 usergrData = self.get_usergroup_data("up_down_usergroup") self.usergroup.click_left_usergroup() #点击展开按钮 self.usergroup.click_usergroup_switch() for dataRow in range(len(usergrData)): data = usergrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.usergroup.usergroup_click_basic_operation(int(data[4]), data[2], data[3]) self.log.log_detail(data[0], True) except Exception as e: print ("up_down_usergroup fail:" + str(e)) self.log.log_end("up_down_usergroup") u'''上移和下移用户组校验''' def up_down_usergroup_check_003(self): #日志开始记录 self.log.log_start("up_down_usergroup_check") #无检查点的测试项标识,如果为True说明通过 flag = False #获取上移用户组测试数据 usergrData = self.get_usergroup_data("up_down_usergroup") #保存成功的弹出框 usergrMsg = self.testrole.popup() self.usergroup.click_left_usergroup() #点击展开按钮 self.usergroup.click_usergroup_switch() for dataRow in range(len(usergrData)): data = usergrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.usergroup.usergroup_click_up_down_check(int(data[4]), data[2], data[3]) self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", usergrMsg, data, flag) except Exception as e: print ("up_down_usergroup_check fail:" + str(e)) self.log.log_end("up_down_usergroup_check") u'''检验添加和编辑用户组''' def check_add_edit_usergroup_004(self): #日志开始记录 self.log.log_start("check_add_edit_usergroup") #获取检验添加用户组测试数据 usergrData = self.get_usergroup_data("check_add_edit_usergroup") #保存成功的弹出框 usergrMsg = self.testrole.popup() #页面弹出框的文本信息 pagetext = u"警告" self.usergroup.click_left_usergroup() #无检查点的测试项标识,如果为True说明通过 flag = False #点击展开按钮 self.usergroup.click_usergroup_switch() for dataRow in range(len(usergrData)): data = usergrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.usergroup.usergroup_click_basic_operation(int(data[4]), data[2], data[3]) if dataRow != 1 and dataRow != 2: self.dptment.popup_sendkey(data[5]) if dataRow == 2: self.dptment.clear_depart_text() self.dptment.click_ok_button() self.frameElem.switch_to_content() self.dptment.multil_div_check_point("xpath", usergrMsg, data, flag, pagetext) self.driver.implicitly_wait(20) self.frameElem.switch_to_content() self.dptment.click_cancel_button() except Exception as e: print ("check_add_edit_usergroup fail:" + str(e)) self.log.log_end("check_add_edit_usergroup") u'''删除用户组''' def del_usergroup_005(self): #日志开始记录 self.log.log_start("del_usergroup") #删除的弹出框 usergrMsg = self.testrole.popup() #获取删除用户组测试数据 usergrData = self.get_usergroup_data("del_usergroup") self.usergroup.click_left_usergroup() #无检查点的测试项标识,如果为True说明通过 flag = False #点击展开按钮 self.usergroup.click_usergroup_switch() for dataRow in range(len(usergrData)): data = usergrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.usergroup.usergroup_click_basic_operation(int(data[4]), data[2], data[3]) self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", usergrMsg, data, flag) self.frameElem.switch_to_content() self.cmf.click_msg_button(1) except Exception as e: print ("del_usergroup fail:" + str(e)) self.log.log_end("del_usergroup") u'''用户组中添加用户''' def usergroup_add_user_001(self): #日志开始记录 self.log.log_start("usergroup_add_user") #获取添加用户组测试数据 usergrData = self.get_usergroup_data("usergroup_add_user") #保存成功的弹出框 usergrMsg = self.testrole.popup() self.usergroup.click_left_usergroup() #无检查点的测试项标识,如果为True说明通过 flag = False #点击展开按钮 self.usergroup.click_usergroup_switch() for dataRow in range(len(usergrData)): data = usergrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: time.sleep(3) self.usergroup.click_usergroup_add_user(data[3], data[2]) self.regroup.check_depart(data[4]) self.usergroup.click_usergroup_add_user_query() self.regroup.check_all_resource() self.regroup.click_resource_okbutton() self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", usergrMsg, data, flag) except Exception as e: print ("usergroup_add_user fail:" + str(e)) self.log.log_end("usergroup_add_user") u'''用户组中查询用户账号/名称''' def query_usergroup_002(self): #日志开始记录 self.log.log_start("query_usergroup") self.usergroup.click_left_usergroup() #点击展开按钮 self.usergroup.click_usergroup_switch() #获取查询用户组测试数据 usergrData = self.get_usergroup_data("query_usergroup") for dataRow in range(len(usergrData)): data = usergrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: if dataRow == 1: #选中用户组 self.dptment.click_basic_operation_public_method(data[2], "user_group_", "_span") self.regroup.click_regroup_reset() else: self.usergroup.set_username(data[3]) self.usergroup.click_usergroup_query() self.regroup.click_regroup_reset() self.log.log_detail(data[0], True) except Exception as e: print ("query_usergroup fail:" + str(e)) self.log.log_end("query_usergroup") u'''用户组删除用户''' def usergroup_del_user_003(self): #日志开始记录 self.log.log_start("usergroup_del_user") #删除的弹出框 usergrMsg = self.testrole.popup() #获取删除用户组测试数据 usergrData = self.get_usergroup_data("usergroup_del_user") self.usergroup.click_left_usergroup() #点击展开按钮 self.usergroup.click_usergroup_switch() flag = False for dataRow in range(len(usergrData)): data = usergrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.usergroup.click_usergroup_del_user(data[3], data[4]) self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", usergrMsg, data, flag) self.frameElem.switch_to_content() self.cmf.click_msg_button(1) except Exception as e: print ("usergroup_del_user fail:" + str(e)) self.log.log_end("usergroup_del_user") u'''用户组全选删除用户''' def usergroup_bulk_user_004(self): #日志开始记录 self.log.log_start("usergroup_bulk_user") #删除的弹出框 usergrMsg = self.testrole.popup() #获取删除用户组测试数据 usergrData = self.get_usergroup_data("usergroup_bulk_user") self.usergroup.click_left_usergroup() #点击展开按钮 self.usergroup.click_usergroup_switch() flag = False for dataRow in range(len(usergrData)): data = usergrData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.usergroup.click_usergroup_bulk_user(data[3]) self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", usergrMsg, data, flag) self.frameElem.switch_to_content() self.cmf.click_msg_button(1) except Exception as e: print ("usergroup_bulk_user fail:" + str(e)) self.log.log_end("usergroup_bulk_user")