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()
def test_001_language(self): #待后续调整,目前只有一个 u'''网管策略 语言管理''' languageA = getAssertText('languageA') language = ManagementPolicyPage(self.driver, self.url) #判断语言 显示 languageText = str(language.getText_byXpath(language.languageText)) self.assertEqual(languageText, languageA, msg='语言 显示字符异常') self.driver.quit() logger.info('test_001_language passed')
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')
def test_004_accesscontrol_Language(self): u'''设备访问控制/WEB语言''' accesscontrol = ManagementPolicyPage(self.driver, self.url) accesscontrol.click_lanAccessControl() time.sleep(1) switch = str( accesscontrol.getAttribute_byXpath( accesscontrol.innerAccessControlCs, 'checked')) self.assertEqual(switch, 'true', msg='内网访问控制默认未关闭') languageA = getAssertText('languageA') language = ManagementPolicyPage(self.driver, self.url) language.click_Language() time.sleep(1) languageText = str(language.getText_byXpath(language.languageText)) self.assertEqual(languageText, languageA, msg='语言 显示字符异常') self.driver.quit() logger.info('test_004_accesscontrol_Language passed')
def test_004_test4(self): u'''删除新增账号 admin登录验证''' #删除test1/test1,会退出当前登陆(test1已经修改了权限 用admin删除) 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) #删除test1/test1 administrator.click_listDelete1() time.sleep(1) administrator.click_ok() time.sleep(1) # 断言列表框里第二行没有值、元素为空:代表删除成功 list2_nodata = administrator.getText_byXpath( administrator.list2_nodata) if list2_nodata != ' ': CapPic(self.driver) logger.info(u'删除test1/test1 有误') raise Exception('删除test1/test1 有误') else: print('删除test1/test1 通过') self.driver.quit() #删除后使用test1不可以登录 login.test_unableLoginWeb(self, username='******', password='******') time.sleep(1) self.driver.quit() #使用admin/admin可以登陆 login.test_enableLoginWeb(self, username='******', password='******') time.sleep(1) self.driver.quit() print('管理员账号测试 验证通过')