def test_002_FreeAuthIP(self): u'''免认证 - IP地址''' pcaddr = socket.gethostbyname(socket.getfqdn( socket.gethostname())) # 获取本机ip 默认有线地址 # 免认证选择IP地址 time.sleep(2) freeauth = Organization_userAuthPage(self.driver, self.url) freeauth.click_noConfig() time.sleep(1) freeauth.click_userip() time.sleep(1) freeauth.input_starip(pcaddr) freeauth.input_endip(pcaddr) freeauth.click_save() time.sleep(5) self.driver.quit() # 打开网页验证 断言 self.driver = webdriver.Chrome() self.driver.get('http://www.baidu.com') time.sleep(2) title1 = self.driver.title # print(title1) self.assertEqual(title1, '百度一下,你就知道', msg='免认证-IP地址 出错') self.driver.quit() logger.info('test_002_FreeAuthIP passed')
def test_003_closeRemoteAuth(self): u'''关闭远程认证''' if Support == '√': logger.info(u'参数支持远程认证') login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) remoteauth = Organization_userAuthPage(self.driver, self.url) remoteauth.click_UserManage() time.sleep(0.3) remoteauth.click_userAuth() time.sleep(1) # 关闭web认证 remoteauth.click_remoteAuthC() time.sleep(1) # 断言 提示信息是否有误 status = str( remoteauth.getAttribute_byXpath(remoteauth.remoteAuthCs, 'checked')) self.assertEqual(status, 'true', msg='远程认证关闭出错') print('远程认证关闭') # 免认证选择 全部用户,然后关闭免认证 remoteauth.click_noConfig() time.sleep(1) remoteauth.click_alluser() time.sleep(0.5) remoteauth.click_save() time.sleep(1) remoteauth.click_FreeAuthC() time.sleep(2) # 断言 提示信息是否有误 status2 = str( remoteauth.getAttribute_byXpath(remoteauth.FreeAuthCs, 'checked')) self.assertEqual(status2, 'true', msg='免认证关闭出错') print('免认证关闭') self.driver.quit() # 清空组织架构组 organization_group.import_empty_template(self) # 判断组织架构是否有其他组 有则清空 print('删除组织架构组 完成') elif Support == '×': logger.info(u'参数不支持远程认证') logger.info('test_003_closeRemoteAuth passed')
def test_001_FreeAuthgroup(self): u'''免认证 - 组织成员''' self.driver.quit() organization_group.import_empty_template(self) # 判断组织架构是否有其他组 有则清空 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) freeauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 freeauth.click_UserManage() time.sleep(0.5) freeauth.click_userAuth() time.sleep(1) #免认证选择组织架构 freeauth.click_noConfig() time.sleep(1) freeauth.click_usergroup() time.sleep(1) # 组织架构,这里选择的是ROOT 所有 freeauth.click_Root() time.sleep(0.5) freeauth.click_save() time.sleep(1) self.driver.quit() # 新增用户组及普通IP用户 organization_group.add_user(self) #打开网页验证 断言 self.driver = webdriver.Chrome() self.driver.implicitly_wait(10) self.driver.get('http://www.baidu.com') time.sleep(2) title1 = self.driver.title # print(title1) self.assertEqual(title1, '百度一下,你就知道', msg='免认证-组织架构 出错') self.driver.quit() print('免认证 - 组织成员 验证成功') #导入空组织架构 以 清空 organization_group.import_empty_template(self) logger.info('test_001_FreeAuthgroup passed')
def test_003_FreeAuthAll(self): u'''免认证 - 所有用户''' time.sleep(2) freeauth = Organization_userAuthPage(self.driver, self.url) freeauth.click_noConfig() time.sleep(1) freeauth.click_alluser() time.sleep(0.5) freeauth.click_save() time.sleep(5) # 打开网页验证 断言 self.driver.get('http://www.baidu.com') time.sleep(2) title1 = self.driver.title # print(title1) self.assertEqual(title1, '百度一下,你就知道', msg='免认证 组织架构 出错') self.driver.quit() logger.info('test_003_FreeAuthAll passed')
def test_002_remoteAuth_FreeAuth(self): u'''认证弹窗测试&&免认证测试''' if Support == '√': logger.info(u'参数支持远程认证') saveSucess = getAssertText('saveSucess') self.driver = webdriver.Chrome() # self.driver.maximize_window() self.driver.implicitly_wait(10) #打开网页测试 self.driver.get('http://www.utt.com.cn') time.sleep(2) title1 = self.driver.title now_url = self.driver.current_url print(title1, now_url) # self.assertEqual(title1, '艾泰科技', msg='认证页面跳转不正常') 如 self.assertIn('http://auth.greenwifi.com.cn', now_url, msg='认证页面跳转不正常') self.driver.quit() print('远程认证 弹窗验证成功') #打开组织架构的免认证 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) remoteauth = Organization_userAuthPage(self.driver, self.url) remoteauth.click_UserManage() time.sleep(0.3) remoteauth.click_userAuth() time.sleep(1) # 免认证选择组织架构 remoteauth.click_noConfig() time.sleep(1) remoteauth.click_usergroup() time.sleep(1) # 组织架构,这里选择的是ROOT 所有 remoteauth.click_Root() time.sleep(0.5) remoteauth.click_save() time.sleep(1) # 开启免认证 remoteauth.click_FreeAuthEn() time.sleep(2) # 断言 提示信息是否有误 pageTip = str(remoteauth.getText_byClass(remoteauth.pageTip)) time.sleep(1) self.assertEqual(pageTip, saveSucess, msg='免认证开启出错') self.driver.quit() print('免认证开启') # 打开网页测试 time.sleep(5) self.driver = webdriver.Chrome() # self.driver.maximize_window() self.driver.implicitly_wait(10) self.driver.get('http://www.baidu.com') time.sleep(2) title3 = self.driver.title print(title3) self.assertEqual(title3, '百度一下,你就知道', msg='开启免认证后 不能直接打开网页') self.driver.quit() elif Support == '×': logger.info(u'参数不支持远程认证') logger.info('test_002_remoteAuth_FreeAuth passed')