Exemple #1
0
    def setUpClass(cls):
        BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        conf = ConfigParser()
        conf.read(os.path.join(BASE_DIR, 'cfginfo.ini'), encoding='utf-8')
        conf.sections()
        cls.url = conf.get('URL', 'url')
        cls.homeUrl = conf.get('URL', 'homeurl')
        username = conf.get('LOGIN', 'username')
        cls.password = conf.get('LOGIN', 'password')
        cls.checkKey = conf.get('LOGIN', 'checkKey')
        cls.username = conf.get('USER', 'username')
        cls.deptname = conf.get('USER', "deptname")
        cls.userId = conf.get('USER', 'userId')
        cls.mobile = conf.get('USER', 'mobile')
        cls.email = conf.get('USER', 'email')
        cls.sort = conf.get('USER', 'sort')
        cls.relate_deptname = conf.get('USER', "relate_deptname")
        cls.relate_role = conf.get('USER', 'relate_role')
        cls.username_new = conf.get('USER', "username_new")
        cls.deptname_new = conf.get('USER', "deptname_new")
        cls.mobile_new = conf.get('USER', 'mobile_new')
        cls.email_new = conf.get('USER', 'email_new')
        cls.sort_new = conf.get('USER', 'sort_new')
        cls.userId_new = conf.get('USER', 'userId_new')
        cls.relate_deptname_new = conf.get('USER', "relate_deptname_new")
        cls.relate_role_new = conf.get('USER', 'relate_role_new')
        cls.user1 = conf.get('USER', 'user1')
        cls.user2 = conf.get('USER', 'user2')
        cls.sort98 = conf.get('USER', 'sort98')
        cls.sort99 = conf.get('USER', 'sort99')
        cls.username_e = conf.get('USER', 'username_e')
        cls.userId_e = conf.get('USER', 'userId_e')
        cls.username_s = conf.get('USER', 'username_s')
        cls.userId_s = conf.get('USER', 'userId_s')
        cls.username_d = conf.get('USER', 'username_d')
        cls.userId_d = conf.get('USER', 'userId_d')
        cls.userId1 = conf.get('USER', 'userId1')
        cls.userId2 = conf.get('USER', 'userId2')

        cls.parentdept1 = conf.get('USER', 'parentdept1')
        cls.parentdept2 = conf.get('USER', 'parentdept2')
        cls.parentdept3 = conf.get('USER', 'parentdept3')
        # 清空自己创建的历史数据并创建上级部门
        test_data.init_data()
        print("通过数据库新增上级部门1:" + cls.parentdept1 + ",部门2:" + cls.parentdept2 +
              ",部门3:" + cls.parentdept3)

        print('开始执行用户管理脚本')
        dr = webdriver.Chrome()  #打开Chrome浏览器
        cls.dr = dr
        print('登录统一开发平台')
        dr.get(cls.url)  #打开统一平台地址
        dr.maximize_window()  #将浏览器最大化
        login(dr, username, cls.password, cls.checkKey)  #输入用户名、密码、验证码后登陆
        for i in range(10):
            if dr.current_url == cls.homeUrl:
                break
            else:
                print('登录等待中...')
                sleep(2)
Exemple #2
0
 def setUp(self):
     print(time.strftime("%Y_%m_%d_%H_%M_%S"))
     dr = webdriver.Chrome()  # 打开Chrome浏览器
     self.dr = dr
     print('登录统一开发平台')
     dr.get(self.url)  # 打开统一平台地址
     dr.maximize_window()  # 将浏览器最大化
     login(dr, self.username_admin, self.password,
           self.checkKey)  # 输入用户名、密码、验证码后登陆
     for i in range(10):
         if dr.current_url == self.homeUrl:
             break
         else:
             print('登录等待中...')
             sleep(2)
     self.assertEqual(dr.current_url, self.homeUrl,
                      msg="登录平台异常")  #检查登陆是否成功或页面刷新后是否返回首页
     print('当前处于首页状态')
     sleep(2)
     #点击系统管理按钮
     User(dr).sys_manger_btn.click()
     print("点击左侧菜单’系统管理‘")
     sleep(1)
     #点击用户管理标签页
     User(dr).user_btn.click()
     print("点击左侧菜单’用户管理‘")
     sleep(1)
     #检查是否打开用户管理标签页
     self.assertNotEqual(User(dr).curr_lable, False, msg="未打开用户管理标签页")
     self.assertEqual(User(dr).curr_lable.text, '用户管理', msg="打开的不是用户管理标签页")
    def setUpClass(cls):
        conf = ConfigParser()
        conf.read("../cfginfo.ini", encoding="utf-8")
        conf.sections()
        url = conf.get('URL', 'url')
        cls.homeUrl = conf.get('URL', 'homeUrl')
        username = conf.get('LOGIN', 'username')
        password = conf.get('LOGIN', 'password')
        checkKey = conf.get('LOGIN', 'checkKey')
        cls.deptname = conf.get('DEPARTMENT', 'deptname')
        cls.deptnameEdit = conf.get('DEPARTMENT', 'deptnameEdit')
        cls.childDepartname = conf.get('DEPARTMENT', 'childDepartName')
        cls.deptnameinit1 = conf.get('DEPARTMENT', 'deptnameinit1')
        cls.deptnameinit2 = conf.get('DEPARTMENT', 'deptnameinit2')
        cls.sort4 = conf.get('DEPARTMENT', 'sort4')
        cls.sort1 = conf.get('DEPARTMENT', 'sort1')
        cls.department1 = conf.get('DEPARTMENT', 'department1')
        cls.department2 = conf.get('DEPARTMENT', 'department2')
        cls.sort98 = conf.get('DEPARTMENT', 'sort98')
        cls.sort99 = conf.get('DEPARTMENT', 'sort99')

        print("开始执行部门管理脚本")
        dr = webdriver.Chrome()  #启动chrom浏览器
        cls.dr = dr
        print("登陆统一开发平台")
        dr.get(url)  #打开统一平台地址
        dr.maximize_window()  #将浏览器最大化
        variable.login(dr, username, password, checkKey)  #输入用户名、密码、验证码后登陆
        for i in range(10):
            if dr.current_url == cls.homeUrl:
                break
            else:
                print("登陆等待中...")
                sleep(2)
Exemple #4
0
    def test_5_reMou(self):
        """角色关联模块"""
        print("继承上一个用例角色" + self.rolename3 + "已经关联用户" + self.user1)
        dr = self.dr
        dr.switch_to.frame(Role(self.dr).iframe_sw[1])
        sleep(1)
        print("进入角色" + self.rolename3 + "的配置模块页面")
        Role(dr).operation(depName=self.rolename3, ope='配置模块').click()
        sleep(1)
        dr.switch_to.frame(
            dr.find_element_by_xpath(
                "//iframe[contains(@src,'/udp/role/selectModuleForRole?')]"))
        print("选择部门管理模块")
        element = Role(dr).Module_checkBox(module="部门管理")
        element.click()
        sleep(3)
        self.assertIn(
            Role(dr).Module_checkBox(module="部门管理").get_attribute("class"),
            "button chk checkbox_true_full_focus")
        Role(dr).add_Mod_submit.click()
        sleep(1)
        print("使用" + self.user1 + "账号登陆平台")
        dr1 = webdriver.Chrome()
        dr1.get(self.url)
        dr1.maximize_window()  # 将浏览器最大化
        sleep(1)
        variable.login(dr1, self.user1, self.password, self.checkKey)
        for i in range(10):
            if dr1.current_url == self.homeUrl:
                print("登陆成功")
                break
            else:
                print("登陆等待中...")
                sleep(2)

        try:
            elenium = variable.check_modules(dr1, parent="系统管理", child="部门管理")
            self.assertNotEqual(elenium, False)
            print(self.user1 + "账号下含有部门管理模块")
            print("admin账号删除账号" + self.user1 + "下的部门管理")
            Role(dr).Module_checkBox(module="部门管理").click()
            sleep(1)
            self.assertIn(
                Role(dr).Module_checkBox(module="部门管理").get_attribute("class"),
                "button chk checkbox_false_full_focus")
            Role(dr).add_Mod_submit.click()
            sleep(1)
            dr1.refresh()
            sleep(1)
            print("检查" + self.user1 + "用户下是否含有部门管理模块")
            elenium = variable.check_modules(dr1, parent="系统管理")
            self.assertEqual(elenium, False)
            print("账号" + self.user1 + "下没有系统管理菜单")
            dr1.quit()
        except:
            dr1.quit()
            raise ("角色权限验证失败")
    def setUpClass(cls):
        BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        conf = ConfigParser()
        conf.read(os.path.join(BASE_DIR, 'cfginfo.ini'), encoding='utf-8')
        conf.sections()
        cls.url = conf.get('URL','url')
        cls.homeUrl = conf.get('URL','homeurl')
        username = conf.get('LOGIN','username')
        cls.password = conf.get('LOGIN','password')
        cls.checkKey = conf.get('LOGIN', 'checkKey')
        cls.modulename = conf.get('MODULE','modulename')
        cls.moduleurl = conf.get('MODULE','moduleurl')
        cls.modulesort = conf.get('MODULE','modulesort')
        cls.parentname = conf.get('MODULE', 'parentname')
        cls.isvisible_add = conf.get('MODULE','isvisible_add')
        cls.ispublic_add = conf.get('MODULE','ispublic_add')
        cls.target = conf.get('MODULE','target')
        cls.alert_url = conf.get('MODULE','alert_url')
        cls.modulename_new = conf.get('MODULE', 'modulename_new')
        cls.moduleurl_new = conf.get('MODULE', 'moduleurl_new')
        cls.modulesort_new = conf.get('MODULE', 'modulesort_new')
        cls.parentname_new = conf.get('MODULE','parentname_new')
        cls.module1 = conf.get('MODULE','module1')
        cls.module2 = conf.get('MODULE', 'module2')
        cls.sort98 = conf.get('MODULE','sort98')
        cls.sort99 = conf.get('MODULE','sort99')
        cls.modulename_public = conf.get('MODULE','modulename_public')
        cls.userid = conf.get("MODULE",'userid')
        cls.modulename_visible=conf.get('MODULE','modulename_visible')
        print('开始执行模块管理脚本')

        cls.parentmodule1 = conf.get('MODULE', 'parentmodule1')
        cls.parentmodule2 = conf.get('MODULE', 'parentmodule2')
        cls.dept = conf.get('MODULE','dept')
        cls.user = conf.get('MODULE', 'user')
        # 清空自己创建的历史数据并创建上级模块
        test_dataForModule.init_data()
        print("通过数据库新增上级模块1:" + cls.parentmodule1 + ",模块2:" + cls.parentmodule2 + ",模块3:" + cls.modulename_public+",模块4:" + cls.modulename_visible+",部门:" + cls.dept+",用户:" + cls.user)

        dr =webdriver.Chrome()  #打开Chrome浏览器
        cls.dr = dr
        print('登录统一开发平台')
        dr.get(cls.url)    #打开统一平台地址
        dr.maximize_window()  #将浏览器最大化
        login(dr,username,cls.password,cls.checkKey)    #输入用户名、密码、验证码后登陆
        for i in range(10):
            if dr.current_url == cls.homeUrl:
                break
            else:
                print('登录等待中...')
                sleep(2)
Exemple #6
0
 def test_4_activate_user(self):
     '''激活用户'''
     print("--------------------激活用户-----------------------")
     dr = self.dr
     sleep(1)
     dr.switch_to.frame(User(dr).iframe_sw[1])
     sleep(1)
     # 搜索禁用用户
     User(dr).disable_user.click()
     sleep(1)
     User(dr).button_able_user.click()
     sleep(1)
     User(dr).btn_search.click()
     print("点击查询按钮")
     sleep(2)
     # 点击查看用户按钮
     element = User(dr).operation(username=self.username_ope, ope="查看")
     sleep(1)
     dr.execute_script("arguments[0].click();", element)
     sleep(2)
     print("点击查看按钮")
     sleep(2)
     dr.switch_to.frame(User(dr).iframe_dep)
     sleep(1)
     User(dr).view_able_user.click()
     print("点击激活按钮")
     sleep(1)
     ts = User(dr).toast_info.get_attribute('textContent')
     self.assertEqual(ts, "激活成功")
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(2)
     ActionChains(dr).move_to_element(User(dr).name).perform()
     sleep(5)
     # 点击退出按钮
     User(dr).logout.click()
     sleep(1)
     login(dr, self.userId_ope, self.password,
           self.checkKey)  # 输入用户名、密码、验证码后登陆
     sleep(2)
     # 验证登录之后修改密码页
     self.assertEqual(User(dr).login_submit.text,
                      "提交",
                      msg="测试用户" + self.userId_ope + "未成功登录")
 def test_9a_public_module(self):
     '''公开模块验证'''
     print("--------------------公开模块验证-----------------------")
     dr =self.dr
     print("数据库初始化:插入模块不公开")
     dr.switch_to.frame(User(dr).iframe_sw[1])
     sleep(1)
     # 验证模块不公开
     element = variable.check_modules(dr, parent=self.modulename_public)
     self.assertEqual(element, False, msg="数据库插入模块公开")
     # 点击编辑按钮
     element = Module(dr).operation(self.modulename_public, '编辑')
     dr.execute_script("arguments[0].click();", element)
     sleep(1)
     dr.switch_to.frame(Module(dr).iframe_d)
     sleep(1)
     print("修改模块,设置为公开")
     Module(dr).module_ispublic.click()
     sleep(1)
     Module(dr).module_public.click()
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(1)
     Module(dr).confirm_button.click()
     sleep(1)
     print("点击确定按钮")
     sleep(1)
     #用户登录系统查看模块:公开
     dr1 = webdriver.Chrome()
     dr1.get(self.url)
     dr1.maximize_window()  # 将浏览器最大化
     login(dr1, self.userid, self.password, self.checkKey)  # 输入用户名、密码、验证码后登陆
     for i in range(10):
         if dr1.current_url == self.homeUrl:
             break
         else:
             print('登录等待中...')
             sleep(2)
     self.assertEqual(dr.current_url,self.homeUrl,msg="登录平台异常")
     try:
         element = variable.check_modules(dr1, parent=self.modulename_public)
         self.assertNotEqual(element, False)
         print(self.modulename_public + "模块公开展示")
     except:
         dr1.quit()
         raise ("设置公开的模块未公开展示")
Exemple #8
0
 def test_1_modify_password(self):
     '''创建用户修改密码'''
     print("--------------------创建用户修改密码-----------------------")
     dr = self.dr
     sleep(2)
     #新增用户
     print("创建用户修改密码")
     User(dr).add_user_model(parentdept=self.parentdept1,
                             username=self.username_ope,
                             userId=self.userId_ope,
                             mobile=self.mobile,
                             email=self.email,
                             sort=self.sort)
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(1)
     ActionChains(dr).move_to_element(User(dr).name).perform()
     sleep(5)
     #点击退出按钮
     User(dr).logout.click()
     print("退出系统管理员账号")
     sleep(1)
     #新增的用户登录修改密码
     print("普通用户登录修改密码")
     login(dr, self.userId_ope, self.password,
           self.checkKey)  # 输入用户名、密码、验证码后登陆
     sleep(2)
     #修改密码
     User(dr).oldPassword.send_keys(self.password)
     sleep(2)
     User(dr).newPassword.send_keys(self.new_password)
     sleep(2)
     User(dr).confirmPassword.send_keys(self.new_password)
     sleep(2)
     User(dr).login_submit.click()
     sleep(1)
     try:
         text = User(dr).toast_info.get_attribute(
             'textContent')  #info消息偶尔会定位失败
         self.assertEqual(text, "密码修改成功")
     except:
         raise ("密码修改失败")
Exemple #9
0
 def test_2_init_password(self):
     '''初始化用户'''
     print("--------------------初始化用户-----------------------")
     dr = self.dr
     dr.switch_to.frame(User(dr).iframe_sw[1])
     sleep(2)
     # 点击查看用户按钮
     print("点击查看用户:" + self.username_ope)
     element = User(dr).operation(username=self.username_ope, ope="查看")
     sleep(1)
     dr.execute_script("arguments[0].click();", element)
     sleep(1)
     print("点击查看按钮")
     sleep(2)
     dr.switch_to.frame(User(dr).iframe_dep)
     sleep(1)
     User(dr).view_init_password.click()
     print("点击初始化密码按钮")
     sleep(1)
     ts = User(dr).toast_info.get_attribute('textContent')
     self.assertEqual(ts, "初始化密码成功", msg="初始化密码失败")
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(2)
     ActionChains(dr).move_to_element(User(dr).name).perform()
     sleep(5)
     # 点击退出按钮
     User(dr).logout.click()
     sleep(1)
     print("退出系统管理员账号")
     # 新增的用户登录修改密码
     login(dr, self.userId_ope, self.password,
           self.checkKey)  # 输入用户名、密码、验证码后登陆
     #验证登录之后修改密码页
     sleep(2)
     self.assertEqual(User(dr).login_submit.text,
                      "提交",
                      msg="测试用户" + self.userId_ope + "未成功登录")
Exemple #10
0
    def setUpClass(cls):
        test_dataForRole.clear_data()
        BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        conf = ConfigParser()
        conf.read(os.path.join(BASE_DIR, 'cfginfo.ini'), encoding='utf-8')
        conf.sections()
        cls.url = conf.get('URL', 'url')
        cls.homeUrl = conf.get('URL', 'homeUrl')
        username = conf.get('LOGIN', 'username')
        cls.password = conf.get('LOGIN', 'password')
        cls.checkKey = conf.get('LOGIN', 'checkKey')
        cls.rolename = conf.get('ROLE', 'rolename')
        cls.rolename2 = conf.get('ROLE', 'rolename2')
        cls.rolename3 = conf.get('ROLE', 'rolename3')
        cls.rolename4 = conf.get('ROLE', 'rolename4')
        cls.rolename5 = conf.get('ROLE', 'rolename5')
        cls.sort1 = conf.get('ROLE', 'sort1')
        cls.remarks = conf.get('ROLE', 'remarks')
        cls.sort4 = conf.get('ROLE', 'sort4')
        cls.user1 = conf.get('ROLE', 'user1')
        cls.departname = conf.get('ROLE', 'departnamesql')

        print("通过数据库新增角色" + cls.rolename3 + ",部门:" + cls.departname + ",用户:" +
              cls.user1)
        test_dataForRole.init_data()

        print("开始执行角色管理脚本")
        dr = webdriver.Chrome()  #启动chrom浏览器
        cls.dr = dr
        print("登陆统一开发平台")
        dr.get(cls.url)  #打开统一平台地址
        dr.maximize_window()  #将浏览器最大化
        variable.login(dr, username, cls.password,
                       cls.checkKey)  #输入用户名、密码、验证码后登陆
        for i in range(10):
            if dr.current_url == cls.homeUrl:
                break
            else:
                print("登陆等待中...")
        sleep(2)
Exemple #11
0
 def test_3_disable_user(self):
     '''禁用用户'''
     print("--------------------禁用用户-----------------------")
     dr = self.dr
     sleep(1)
     dr.switch_to.frame(User(dr).iframe_sw[1])
     sleep(2)
     # 点击查看用户按钮
     element = User(dr).operation(username=self.username_ope, ope="查看")
     sleep(1)
     dr.execute_script("arguments[0].click();", element)
     sleep(1)
     print("点击查看按钮")
     sleep(2)
     dr.switch_to.frame(User(dr).iframe_dep)
     sleep(1)
     User(dr).view_disable_user.click()
     print("点击禁用按钮")
     sleep(1)
     ts = User(dr).toast_info.get_attribute('textContent')
     sleep(1)
     self.assertEqual(ts, "禁用成功")
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(2)
     ActionChains(dr).move_to_element(User(dr).name).perform()
     sleep(5)
     # 点击退出按钮
     User(dr).logout.click()
     sleep(1)
     login(dr, self.userId_ope, self.password,
           self.checkKey)  # 输入用户名、密码、验证码后登陆
     sleep(2)
     self.assertEqual(User(dr).login_msg.text, "用户被禁用")
Exemple #12
0
 def test_5_clearUserLock(self):
     '''解除锁定'''
     print("--------------------解除锁定-----------------------")
     dr = self.dr
     sleep(2)
     ActionChains(dr).move_to_element(User(dr).name).perform()
     sleep(5)
     # 点击退出按钮
     User(dr).logout.click()
     sleep(1)
     # 新增的用户登录锁定账号
     login(dr, self.userId_ope, self.new_password,
           self.checkKey)  # 输入用户名、密码、验证码后登陆
     sleep(1)
     self.assertEqual(
         User(dr).login_msg.get_attribute('textContent'), "用户名或密码错误")
     sleep(1)
     User(dr).msg_close.click()
     sleep(1)
     User(dr).button_login_submit.click()
     sleep(1)
     self.assertEqual(
         User(dr).login_msg.get_attribute('textContent'), "用户名或密码错误")
     sleep(1)
     User(dr).msg_close.click()
     sleep(1)
     User(dr).button_login_submit.click()
     sleep(1)
     self.assertEqual(
         User(dr).login_msg.get_attribute('textContent'), "用户名或密码错误")
     sleep(1)
     User(dr).msg_close.click()
     sleep(1)
     User(dr).button_login_submit.click()
     sleep(1)
     self.assertEqual(
         User(dr).login_msg.text, "对不起,因为您输入的密码已经多次错误,该账号将被锁定10分钟。")
     print("用户登录账号或密码错误3次,提示账号锁定")
     User(dr).msg_close.click()
     sleep(1)
     print("点击提示信息关闭按钮")
     login(dr, self.username_admin, self.password, self.checkKey)
     sleep(1)
     # 点击系统管理按钮
     User(dr).sys_manger_btn.click()
     print("点击左侧菜单’系统管理‘")
     sleep(1)
     # 点击用户管理标签页
     User(dr).user_btn.click()
     print("点击左侧菜单’用户管理‘")
     sleep(1)
     dr.switch_to.frame(User(dr).iframe_sw[1])
     sleep(2)
     # 点击查看用户按钮
     element = User(dr).operation(username=self.username_ope, ope="查看")
     sleep(1)
     dr.execute_script("arguments[0].click();", element)
     print("点击查看按钮")
     sleep(2)
     dr.switch_to.frame(User(dr).iframe_dep)
     sleep(1)
     User(dr).view_clearUserLock.click()
     print("点击解除锁定按钮")
     sleep(1)
     ts = User(dr).toast_info.get_attribute('textContent')
     self.assertEqual(ts, "解除锁定成功")
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(1)
     dr.switch_to.parent_frame()
     sleep(2)
     ActionChains(dr).move_to_element(User(dr).name).perform()
     sleep(5)
     # 点击退出按钮
     User(dr).logout.click()
     sleep(1)
     login(dr, self.userId_ope, self.password,
           self.checkKey)  # 输入用户名、密码、验证码后登陆
     sleep(2)
     # 验证登录之后修改密码页
     self.assertEqual(User(dr).login_submit.text,
                      "提交",
                      msg="测试用户" + self.userId_ope + "未成功登录")