コード例 #1
0
 def test_001_test1(self):
     u'''添加管理员账号'''
     roleA = getAssertText('roleA')
     # 添加管理员账号test/test,读写权限
     login.loginWeb(self)  #admin账号登录
     self.driver.implicitly_wait(10)
     administrator = ManagementPolicyPage(self.driver, self.url)
     #进入系统配置-网管策略-系统管理员
     administrator.click_sysConfig()
     time.sleep(0.5)
     administrator.click_ManagementPolicy()
     time.sleep(1)
     # 添加管理员账号test/test
     administrator.click_add()
     time.sleep(1)
     administrator.input_username('test')
     administrator.input_passwd1('test')
     administrator.input_passwd2('test')
     #设置权限变量,选择 读写 权限
     selrole = administrator.selelement_byName(administrator.role)
     Select(selrole).select_by_value('adm')
     administrator.click_save()
     time.sleep(1)
     # 断言 再点击编辑 确认元素不为空(账号确实是test):代表账号确实是test
     list_name1 = administrator.getText_byXpath(administrator.list_name1)
     list_role1 = administrator.getText_byXpath(administrator.list_role1)
     self.assertEqual(list_name1, 'test', msg='新建账号不为test')
     self.assertEqual(list_role1, roleA, msg='新建账号权限不为读写')
     #注销当前登录
     login.logoutWeb(self)
     time.sleep(1)
     self.driver.quit()
コード例 #2
0
 def test_002_test2(self):
     u'''新增账号登录 修改权限'''
     RouteUrl = getweb('RouteUrl')
     self.url = RouteUrl
     #能使用test该账号登陆管理DUT
     login.test_enableLoginWeb(self, username='******', password='******')
     # self.url = RouteUrl
     self.driver.implicitly_wait(10)
     administrator = ManagementPolicyPage(self.driver, self.url)
     administrator.click_sysConfig()
     time.sleep(0.5)
     administrator.click_ManagementPolicy()
     time.sleep(1)
     #修改test/test为test1/test1,(测试:账号权限一起改 提交时候权限未改成功,这里分两步完成)
     administrator.click_listEdit1()
     time.sleep(1)
     administrator.input_username('test1')
     administrator.input_passwd1('test1')
     administrator.input_passwd2('test1')
     administrator.click_save()
     time.sleep(1)
     self.driver.quit()
     #重新登录--只为修改test1的权限(可以使用test1登录也验证了上一步修改成功)
     login.test_enableLoginWeb(self, username='******', password='******')
     self.driver.implicitly_wait(10)
     administrator = ManagementPolicyPage(self.driver, self.url)
     administrator.click_sysConfig()
     time.sleep(0.5)
     administrator.click_ManagementPolicy()
     time.sleep(1)
     #修改test1/test1,为只读权限。
     administrator.click_listEdit1()
     time.sleep(1)
     selrole = administrator.selelement_byName(administrator.role)
     Select(selrole).select_by_value('viewer')  #改为只读权限
     time.sleep(1)
     administrator.click_input_group()  #修改后点击下其他元素,避免没有保存成功
     time.sleep(1)
     administrator.click_save()
     time.sleep(1)
     self.driver.quit()
コード例 #3
0
    def test_002_admin(self):
        u'''多级用户管理:读写/读'''
        roleA = getAssertText('roleA')
        User = getweb('User')
        administrator = ManagementPolicyPage(self.driver, self.url)
        default = str(administrator.getText_byXpath(administrator.defaultAcc))
        defaultRole = str(
            administrator.getText_byXpath(administrator.defaultRole))
        self.assertEqual(default, User, msg='账号不为"admin"')
        self.assertEqual(defaultRole, roleA, msg='admin权限不为"读写"')

        # 查看新增账号的权限
        administrator.click_add()
        time.sleep(1)
        administrator.input_username('test')
        administrator.input_passwd1('test')
        administrator.input_passwd2('test')
        # 设置权限变量,选择 读写 权限
        selrole = administrator.selelement_byName(administrator.role)
        Select(selrole).select_by_value('adm')
        Select(selrole).select_by_value('viewer')
        self.driver.quit()
        logger.info('test_002_admin passed')