Esempio n. 1
0
 def operation(self, depName, ope):
     #self.dr.switch_to.frame(Department(self.dr).iframe_sw[1])
     x = 1
     if ope == "配置模块":
         j = 1
     elif ope == "配置用户":
         j = 2
     elif ope == "编辑":
         j = 3
     elif ope == "删除":
         j = 4
     else:
         raise ("ope输入错误")
     for i in range(300):
         xpath = "/html/body/div/div/div[2]/div/div/div[2]/div[1]/div[2]/table/tbody/" + "tr[" + str(
             x) + "]/" + "td[2]/div"
         tr = wait_element(self.dr, "By.XPATH", xpath)
         if tr == False:
             print("未检查到名称为" + depName + "的部门")
             break
         else:
             if tr.get_attribute('textContent') == depName:
                 xpath = "html/body/div/div/div[2]/div/div/div[2]/div[1]/div[4]/div[2]/table/tbody/" + "tr[" + str(
                     x) + "]/" + "td/div/a[" + str(j) + "]"
                 btn = wait_element(self.dr, "By.XPATH", xpath)
                 return btn
             else:
                 x = x + 1
Esempio n. 2
0
def get_table(dr):
    table=[]
    x = 1
    j = 2
    print("开始获取表格中的数据")
    for i in range(300):  #列表中最多显示300条数据
        xpath = "/html/body/div/div/div[2]/div/div/div[2]/div[1]/div[2]/table/tbody/"+"tr["+str(x)+"]/"+"td["+str(j)+"]/div"
        if wait_element(dr,"By.XPATH",xpath) != False:
            table_char=[]
            for i in range(10):
                tr = wait_element(dr, "By.XPATH", xpath)
                if tr == False:
                    table.append(table_char)
                    break
                else:
                    text = tr.get_attribute('textContent')
                    table_char.append(text)
                    j = j+1
                    xpath = "/html/body/div/div/div[2]/div/div/div[2]/div[1]/div[2]/table/tbody/" + "tr[" + str(
                        x) + "]/" + "td[" + str(j) + "]/div"
            x = x + 1
            j = 2
        else:
            break
    return table
Esempio n. 3
0
def check_modules(dr,parent,child=None):
    if child == None:
        return wait_element(dr,"By.CSS_SELECTOR",attribute="a[lay-tips='"+parent+"']")
    elif child !=None:
        wait_element(dr,"By.CSS_SELECTOR",attribute="a[lay-tips='"+parent+"']").click()
        sleep(1)
        return wait_element(dr, 'By.LINK_TEXT', attribute=u"%s"%(child))
    else:
        raise ("请正确填写入参")
Esempio n. 4
0
 def setUp(self):
     dr = self.dr
     self.assertEqual(dr.current_url, self.homeUrl,
                      msg="登陆平台异常")  #检查登陆是否成功或页面刷新后是否返回首页
     print("当前处于首页状态")
     #点击系统管理按钮
     Role(dr).sys_manger_btn.click()
     print("点击左侧菜单’系统管理‘")
     sleep(1)
     #点击部门管理标签页
     wait_element(self.dr, 'By.LINK_TEXT', u"用户管理").click()
     print("点击左侧菜单’角色管理‘")
Esempio n. 5
0
 def test_2_add(self):
     print(
         "-------------------------开始执行第二条用例:添加一级角色----------------------------------"
     )
     dr = self.dr
     self.dr.switch_to.frame(Role(self.dr).iframe_sw[1])
     sleep(1)
     wait_element(self.dr, 'By.CSS_SELECTOR',
                  "button[lay-event='add']").click()
     sleep(1)
     wait_element(self.dr, 'By.CSS_SELECTOR',
                  "a[class='layui-layer-btn1']").click()
     sleep(15)
Esempio n. 6
0
 def Module_checkBox(self, module):
     for i in range(50):
         i = i + 1
         id = "moduleTree_" + str(i)
         element = wait_element(self.dr, "By.ID", id)
         if element == False:
             print("未找到指定元素")
             break
         else:
             if element.get_attribute("textContent") == module:
                 checkboxId = id + "_check"
                 return wait_element(self.dr, "By.ID", checkboxId)
             else:
                 continue
Esempio n. 7
0
 def role_add(self,
              rolename=None,
              parentrole=None,
              sort=None,
              Ismanger=None,
              remarks=None):
     print("点击添加角色按钮")
     Role(self.dr).add_role.click()
     sleep(1)
     self.dr.switch_to.frame('layui-layer-iframe1')  # 定位到添加弹框
     sleep(1)
     Role(self.dr).input_rolename.send_keys(rolename)
     print("输入角色名称:" + rolename)
     Role(self.dr).input_sort.send_keys(sort)
     if remarks != None:
         Role(self.dr).input_remarks.send_keys(remarks)
     if parentrole != None:
         Role(self.dr).list_parentrole.click()
         sleep(1)
         self.dr.switch_to.frame('layui-layer-iframe1')
         sleep(1)
         for i in range(30):
             id = "ztree_" + str(i + 1) + "_span"
             tree = wait_element(self.dr, "By.ID", id)
             if tree != False:
                 if tree.get_attribute('textContent') == parentrole:
                     tree.click()
                     self.dr.switch_to.parent_frame()
                     sleep(1)
                     Role(self.dr).submit.click()
                     sleep(1)
                     break
             else:
                 raise ("未找到指定的上级角色")
     self.dr.switch_to.parent_frame()  # 确定按钮和弹框不在一个iframe里,需要跳到上级ifranme中
     Role(self.dr).submit.click()
     print("点击确定按钮")
Esempio n. 8
0
 def input_sort(self):
     return wait_element(self.dr, "By.ID", "sort")
Esempio n. 9
0
 def list_parentrole(self):
     return wait_element(self.dr, "By.ID", "parentRoleName")
Esempio n. 10
0
 def input_rolename(self):
     return wait_element(self.dr, "By.ID", "roleName")
Esempio n. 11
0
 def toast_info(self):
     return wait_element(self.dr,
                         "By.CLASS_NAME",
                         "layui-layer-content",
                         timeout=15)
Esempio n. 12
0
 def btn_search(self):
     return wait_element(self.dr, "By.ID", "LAY-app-search")
Esempio n. 13
0
 def tree_admin(self):
     return wait_element(self.dr, 'By.CSS_SELECTOR', "a[title='admin']")
Esempio n. 14
0
 def del_user(self):
     return wait_element(self.dr, 'By.CSS_SELECTOR', "a[lay-event='del']")
Esempio n. 15
0
 def input_user(self):
     return wait_element(self.dr, "By.CSS_SELECTOR",
                         "input[placeholder='请选择'")
Esempio n. 16
0
 def role_btn(self):
     return wait_element(self.dr, 'By.LINK_TEXT', u"角色管理")
Esempio n. 17
0
 def add_user_submit(self):
     return wait_element(self.dr, "By.ID", "addUserBtn")
Esempio n. 18
0
 def btn_batdel(self):
     return wait_element(self.dr, "By.CSS_SELECTOR",
                         "button[lay-event='batchdel']")
Esempio n. 19
0
 def btn_reset(self):
     return wait_element(self.dr, "By.CSS_SELECTOR", "button[type='reset']")
Esempio n. 20
0
 def text_search(self):
     return wait_element(self.dr, "By.ID", 'roleName')
Esempio n. 21
0
 def input_remarks(self):
     return wait_element(self.dr, "By.ID", "backup")
Esempio n. 22
0
def login(dr,username,password,checkKey):
    print("输入用户名"+username)
    wait_element(dr, 'By.ID', 'userId').clear()
    wait_element(dr,'By.ID','userId').send_keys(username)
    sleep(1)
    print("输入密码"+password)
    wait_element(dr, 'By.ID', 'pwd').clear()
    wait_element(dr, 'By.ID', 'pwd').send_keys(password)
    sleep(1)
    print("输入验证码"+checkKey)
    wait_element(dr, 'By.ID', 'captcha').clear()
    wait_element(dr, 'By.ID', 'captcha').send_keys(checkKey)
    sleep(1)
    print("点击登陆按钮")
    wait_element(dr, 'By.CLASS_NAME', 'btn').click()
    sleep(5)
Esempio n. 23
0
 def add_role(self):
     return wait_element(self.dr, 'By.CSS_SELECTOR',
                         "button[lay-event='add']")
Esempio n. 24
0
 def iframe_auto(self):
     return wait_element(self.dr, "By.CSS_SELECTOR",
                         "iframe[scrolling='auto']")
Esempio n. 25
0
 def submit(self):
     return wait_element(self.dr, 'By.CLASS_NAME', "layui-layer-btn0")
Esempio n. 26
0
 def curr_lable(self):
     return wait_element(self.dr, 'By.XPATH',
                         "//*[@class='layui-this']/span")
Esempio n. 27
0
 def role_add_user_btn(self):
     return wait_element(self.dr, "By.CSS_SELECTOR",
                         "button[onclick='showAddUserForm()']")
Esempio n. 28
0
 def add_Mod_submit(self):
     return wait_element(self.dr, "By.ID", "btn-save")
Esempio n. 29
0
 def choose_list(self):
     return wait_element(self.dr, "By.CSS_SELECTOR",
                         "dd[class='layui-this']")
Esempio n. 30
0
 def sys_manger_btn(self):
     return wait_element(self.dr, 'By.CSS_SELECTOR', "a[lay-tips='系统管理']")