def test_003_closeWebAuth(self): u'''关闭web认证''' if Support == '√': logger.info(u'参数支持本地认证') # 打开用户管理 - 用户认证 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) webauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 webauth.click_UserManage() time.sleep(0.5) webauth.click_userAuth() time.sleep(1) # 开启web认证 webauth.click_WebAuthC() time.sleep(1) # 断言 提示信息是否有误 status = str(webauth.getAttribute_byXpath(webauth.WebAuthCs,'checked')) time.sleep(1) self.assertEqual(status, 'true', msg='web认证关闭出错') self.driver.quit() print('web认证关闭 验证成功') # 清空组织架构组 organization_group.import_empty_template(self) # 判断组织架构是否有其他组 有则清空 print('删除组织架构组 完成') elif Support == '×': logger.info(u'参数不支持本地认证') logger.info('test_003_closeWebAuth passed')
def test_001_openRemoteAuth(self): u'''开启远程认证''' if Support == '√': logger.info(u'参数支持远程认证') organization_group.import_empty_template(self) # 判断组织架构是否有其他组 有则清空 # 打开用户管理 - 用户认证 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_remoteAuthEn() time.sleep(0.5) # 断言 提示信息是否有误 status = str( remoteauth.getAttribute_byXpath(remoteauth.remoteAuthEs, 'checked')) self.assertEqual(status, 'true', msg='远程认证开启出错') time.sleep(1) self.driver.quit() print('远程认证 开启成功') # 新增用户组及PC的组织架构 organization_group.add_user(self) time.sleep(1) elif Support == '×': logger.info(u'参数不支持远程认证') logger.info('test_001_openRemoteAuth passed')
def test_003_delAccNumber(self): u'''认证账号 - 删除''' nodata = getAssertText('nodata') login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) pppoeauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 pppoeauth.click_UserManage() time.sleep(0.5) pppoeauth.click_userAuth() time.sleep(1) pppoeauth.click_account() time.sleep(1) pppoeauth.click_selAll() time.sleep(0.5) pppoeauth.click_deleteAll() time.sleep(1) pppoeauth.click_ok() time.sleep(1) list_tips=pppoeauth.getText_byXpath(pppoeauth.list_tips) self.assertEqual(str(list_tips),nodata,msg='账号删除失败') print('认证账号 - 账号删除 验证通过') self.driver.quit() organization_group.group_delete(self) # 删除组 logger.info('test_003_delAccNumber passed')
def setUp(self): logger.info('setUp start') #开启web 认证 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) self.driver.maximize_window() freeauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 freeauth.click_UserManage() time.sleep(0.5) freeauth.click_userAuth() time.sleep(1) # 开启web认证 freeauth.click_WebAuthEn() time.sleep(0.5) # 断言 提示信息是否有误 status1 = str( freeauth.getAttribute_byXpath(freeauth.WebAuthEs, 'checked')) self.assertEqual(status1, 'true', msg='web认证开启出错') print('web认证开启') time.sleep(1) #开启免认证 freeauth.click_FreeAuthEn() time.sleep(0.5) # 断言 提示信息是否有误 status2 = str( freeauth.getAttribute_byXpath(freeauth.FreeAuthEs, 'checked')) self.assertEqual(status2, 'true', msg='免认证开启出错') print('免认证开启')
def tearDown(self): # 关闭web 认证 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) self.driver.maximize_window() freeauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 freeauth.click_UserManage() time.sleep(0.5) freeauth.click_userAuth() time.sleep(1) # 开启web认证 freeauth.click_WebAuthC() time.sleep(1) # 断言 提示信息是否有误 status3 = str( freeauth.getAttribute_byXpath(freeauth.WebAuthCs, 'checked')) self.assertEqual(status3, 'true', msg='web认证关闭出错') print('web认证关闭') time.sleep(2) # 关闭免认证 freeauth.click_FreeAuthC() time.sleep(1) # 断言 提示信息是否有误 status4 = str( freeauth.getAttribute_byXpath(freeauth.FreeAuthCs, 'checked')) self.assertEqual(status4, 'true', msg='免认证关闭出错') print('免认证关闭') self.driver.quit() logger.info('tearDown over') logger.info('%s' % ('=' * 50))
def test_001_openWebAuth(self): u'''web认证开启''' host = gettelnet('host').split(r'.') host1 = host[0] + '.' + host[1] + '.' + host[2] +'.' # 006中设置了指定IP,这里增加一个判断联网 pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname())) print(pcaddr) pingTestIP() # 避免判断失误 p = pingTestIP() if p == 'N' or host1 not in pcaddr: # 如果不通 or 地址不为lan口网段 # 1、改回DHCP, 调用bat脚本 os.system('%s' % (batpath + 'changeDhcpIp.bat')) time.sleep(5) n = 0 while n < 30: # 获取本机ip 默认有线地址,有线断开会显示无线 pcaddr_new = socket.gethostbyname(socket.getfqdn(socket.gethostname())) print(pcaddr_new, n) if '192.168.' not in str(pcaddr_new): time.sleep(2) n += 1 else: print('IP地址已自动获取成功', n) break else: raise Exception('未获取到地址') if Support == '√': logger.info(u'参数支持本地认证') organization_group.import_empty_template(self) # 判断组织架构是否有其他组 有则清空 # 打开用户管理 - 用户认证 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) webauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 webauth.click_UserManage() time.sleep(0.5) webauth.click_userAuth() time.sleep(1) #开启web认证 webauth.click_WebAuthEn() time.sleep(1) # 断言 提示信息是否有误 status = str(webauth.getAttribute_byXpath(webauth.WebAuthEs,'checked')) time.sleep(1) self.assertEqual(status,'true',msg='web认证开启出错') self.driver.quit() elif Support == '×': logger.info(u'参数不支持本地认证') logger.info('test_001_openWebAuth passed')
def test_001_addWebAccNumber(self): u'''认证账号 - web账号''' AccountingType = getAssertText('AccountingType') organization_group.import_empty_template(self) # 判断组织架构是否有其他组 有则清空 # 调用新增组 “SelfComputerTest” organization_group.group_add(self) # 新增web认证账号 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) webauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 webauth.click_UserManage() time.sleep(0.5) webauth.click_userAuth() time.sleep(1) webauth.click_account() time.sleep(1) webauth.click_addUser() time.sleep(1) webauth.input_name('webtest1') # 仅有一个用户组,这里省略 select = webauth.selelement_byName(webauth.authType) Select(select).select_by_value('Web') time.sleep(1) webauth.input_authAccount('webtest1') webauth.input_authPassword('webtest1') webauth.click_save() time.sleep(2) # 断言 添加的账号 认证方式和认证账号 是否正常 list_authtype = webauth.getText_byXpath(webauth.list_authtype) list_authAcc = webauth.getText_byXpath(webauth.list_authAcc) self.assertEqual(str(list_authtype), 'Web', msg='认证方式显示不为“Web”') self.assertEqual(str(list_authAcc), 'webtest1', msg='认证账号不为“webtest1”') print('认证账号 - 新增web账号 验证成功') # 修改web账号的计费方式为日期计费 time.sleep(1) webauth.click_listedit1() time.sleep(1) webauth.click_accountBillEn() time.sleep(0.5) webauth.click_save() time.sleep(1) # 断言 编辑的账号 计费方式是否已开启 list_AccountingType = str(webauth.getText_byXpath(webauth.list_AccountingType)) self.assertEqual(list_AccountingType, AccountingType, msg='web认证账号 修改成功') self.driver.quit() logger.info('test_001_addWebAccNumber passed')
def test_002_addpppoeAccNumber(self): u'''认证账号 - PPPoE账号(部分型号不支持PPPoE server)''' bindingMode = getAssertText('bindingMode') # 开启PPPoE认证 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) pppoeauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 pppoeauth.click_UserManage() time.sleep(0.5) pppoeauth.click_userAuth() time.sleep(1) # 新增pppoe认证账号 pppoeauth.click_account() time.sleep(1) pppoeauth.click_addUser() time.sleep(1) pppoeauth.input_name('pppoetest1') # 仅有一个用户组,这里省略 select = pppoeauth.selelement_byName(pppoeauth.authType) Select(select).select_by_value('PPPoE') time.sleep(1) pppoeauth.input_authAccount('pppoetest1') pppoeauth.input_authPassword('pppoetest1') pppoeauth.click_save() time.sleep(2) # 断言 添加的账号 认证方式和认证账号 是否正常 list_authtype = pppoeauth.getText_byXpath(pppoeauth.list_authtype) list_authAcc = pppoeauth.getText_byXpath(pppoeauth.list_authAcc) self.assertEqual(str(list_authtype), 'PPPoE', msg='认证方式显示不为“PPPoE”') self.assertEqual(str(list_authAcc), 'pppoetest1', msg='认证账号不为“pppoetest1”') print('认证账号 - 新增PPPoE用户 验证成功') # 修改pppoe账号的绑定模式为自动绑定 time.sleep(1) pppoeauth.click_listedit1() time.sleep(1) pppoeauth.click_autoBind() time.sleep(0.5) pppoeauth.click_save() time.sleep(2) # 断言 编辑的账号 绑定模式是否为自动绑定 binding_mode = pppoeauth.getText_byXpath(pppoeauth.list_bindingMode) self.assertEqual(str(binding_mode), bindingMode, msg='pppoe账号 修改成功') self.driver.quit() logger.info('test_002_addpppoeAccNumber 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_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')
def test_001_openPPPoEAuth_addAcc(self): u'''开启PPPoE认证 - 创建PPPoE账号''' # 005中设置了黑名单上网,这里增加一个判断联网 nodata = getAssertText('nodata') # 判断联网 ,不能则改回mac p = pingTestIP('www.baidu.com') if p == 'N': # 将mac改回 # 调用bat脚本 os.system('%s' % (batpath + 'changeMacToBack.bat')) time.sleep(5) n = 0 while n < 30: # 获取本机ip 默认有线地址,有线断开会显示无线 pcaddr_new = socket.gethostbyname( socket.getfqdn(socket.gethostname())) print(pcaddr_new, n) if '192.168.' not in str(pcaddr_new): time.sleep(2) n += 1 else: print('IP地址已自动获取成功', n) break else: # raise Exception('未获取到地址1') # 开启绑定情况下 仅更改mac 可能会获取不到地址 os.system('%s' % (batpath + 'ipconfig_release.bat')) time.sleep(5) os.system('%s' % (batpath + 'ipconfig_renew.bat')) time.sleep(5) i = 0 while i < 30: # 获取本机ip 默认有线地址,有线断开会显示无线 pcaddr_new = socket.gethostbyname( socket.getfqdn(socket.gethostname())) print(pcaddr_new, i) if '192.168.' not in str(pcaddr_new): time.sleep(2) i += 1 else: print('IP地址已自动获取成功2', i) break else: raise Exception('未获取到地址2') # 删除黑名单绑定 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) blacklist = Organization_userBlackPage(self.driver, self.url) # 打开用户管理 - 组织成员 blacklist.click_UserManage() time.sleep(0.5) blacklist.click_blacklist() time.sleep(1) blacklist.click_delete() time.sleep(1) blacklist.click_ok() time.sleep(1) # 断言 开启提示信息是否有误 listtips = str(blacklist.getText_byXpath(blacklist.list_tips)) time.sleep(1) self.assertEqual(listtips, nodata, msg='黑名单用户删除失败') print('黑名单用户已删除') self.driver.quit() organization_group.import_empty_template(self) # 判断组织架构是否有其他组 有则清空 #调用新增组 “SelfComputerTest” organization_group.group_add(self) time.sleep(1) #开启PPPoE认证 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) pppoeauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 pppoeauth.click_UserManage() time.sleep(0.5) pppoeauth.click_userAuth() time.sleep(1) #修改PPPoE服务器配置 pppoeauth.click_PPPoEConfig() time.sleep(2) pppoeauth.input_pppoeStart('10.10.10.1') pppoeauth.input_pppoePriDns('114.114.114.114') pppoeauth.click_PppoeNoticeEn() pppoeauth.input_remainDays('50') #账号到期提前通告时间50天 配合账号将要过期的通告 pppoeauth.click_save() time.sleep(2) #启用pppoe server pppoeauth.click_pppoeAuthEn() time.sleep(1) # 断言 开启提示信息是否有误 status = str( pppoeauth.getAttribute_byXpath(pppoeauth.pppoeAuthEns, 'checked')) time.sleep(1) print(status) self.assertEqual(status, 'true', msg='PPPoE认证开启出错') print('PPPoE认证开启 验证成功') #配置一个不计费的PPPoE账号 pppoeauth.click_account() time.sleep(1) pppoeauth.click_addUser() time.sleep(1) pppoeauth.input_name('pppoeauth') #仅有一个用户组,这里省略 select = pppoeauth.selelement_byName(pppoeauth.authType) Select(select).select_by_value('PPPoE') time.sleep(1) pppoeauth.input_authAccount('pppoeauth') pppoeauth.input_authPassword('pppoeauth') pppoeauth.click_save() time.sleep(2) #断言 添加的账号 认证方式和认证账号 是否正常 list_authtype = pppoeauth.getText_byXpath(pppoeauth.list_authtype) list_authAcc = pppoeauth.getText_byXpath(pppoeauth.list_authAcc) self.assertEqual(str(list_authtype), 'PPPoE', msg='认证方式显示不为“PPPoE”') self.assertEqual(str(list_authAcc), 'pppoeauth', msg='认证账号不为“pppoeauth”') self.driver.quit() logger.info('test_001_openPPPoEAuth_addAcc passed')
def test_003_AuthNotice(self): u'''账号到期通告''' messages = getAssertText('PPPoENotice') login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) pppoeauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 pppoeauth.click_UserManage() time.sleep(0.5) pppoeauth.click_userAuth() time.sleep(1) pppoeauth.click_account() time.sleep(1) # 新增已过期账号 pppoeauth.click_addUser() time.sleep(1) pppoeauth.input_name('BeOverdue') selauthType = pppoeauth.selelement_byName('authType') Select(selauthType).select_by_value('PPPoE') time.sleep(1) pppoeauth.input_authAccount('BeOverdue') pppoeauth.input_authPassword('BeOverdue') pppoeauth.click_accountBillEn() time.sleep(1) #设置账号日期 pppoeauth.click_accountOpenDater() pppoeauth.click_bnpreMonth() #向前一个月 pppoeauth.click_day1() #任意选择 pppoeauth.click_accountStopDate() pppoeauth.click_bnpreMonth() # 向前一个月 pppoeauth.click_day2() pppoeauth.click_save() time.sleep(2) # 断言 添加的账号 认证方式和认证账号 是否正常(第二行) list_authtype2 = pppoeauth.getText_byXpath(pppoeauth.list_authtype2) list_authAcc2 = pppoeauth.getText_byXpath(pppoeauth.list_authAcc2) self.assertEqual(str(list_authtype2), 'PPPoE', msg='认证方式显示不为“PPPoE”') self.assertEqual(str(list_authAcc2), 'BeOverdue', msg='认证账号不为“BeOverdue”') print('认证账号 - 新增已过期账号 成功') # 新增将过期账号 pppoeauth.click_addUser() time.sleep(1) pppoeauth.input_name('Overdue') selauthType = pppoeauth.selelement_byName('authType') Select(selauthType).select_by_value('PPPoE') time.sleep(1) pppoeauth.input_authAccount('Overdue') pppoeauth.input_authPassword('Overdue') pppoeauth.click_accountBillEn() time.sleep(1) # 设置账号日期 pppoeauth.click_accountOpenDater() pppoeauth.click_bnpreMonth() # 向前一个月 pppoeauth.click_day1() # 任意选择 pppoeauth.click_accountStopDate() pppoeauth.click_bnpostMonth() # 向后一个月 pppoeauth.click_day3() pppoeauth.click_save() time.sleep(2) # 断言 添加的账号 认证方式和认证账号 是否正常(第三行) list_authtype3 = pppoeauth.getText_byXpath(pppoeauth.list_authtype3) list_authAcc3 = pppoeauth.getText_byXpath(pppoeauth.list_authAcc3) self.assertEqual(str(list_authtype3), 'PPPoE', msg='认证方式显示不为“PPPoE”') self.assertEqual(str(list_authAcc3), 'Overdue', msg='认证账号不为“BeOverdue”') print('认证账号 - 新增将过期账号 成功') self.driver.quit() #开始验证账号到期通告 # 已过期账号验证 #开始拨号 Adsl.connect(self, name='adsl', username='******', password='******') # 通过断言IP地址网段,判断是否可以拨号成功 pcaddr_connectAdsl = socket.gethostbyname( socket.getfqdn(socket.gethostname())) # print(pcaddr_connectAdsl) self.assertIn('10.10.10.', str(pcaddr_connectAdsl), msg='PPPoE拨号失败') time.sleep(2) # 打开网页测试,测试上网 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 print(title1) self.assertEqual(title1, messages, msg='通告未显示') time.sleep(1) # 拨号挂断,通过断言IP地址网段,判断是否挂断 Adsl.disconnect(self) pcaddr_disconnectAdsl = socket.gethostbyname( socket.getfqdn(socket.gethostname())) print(pcaddr_disconnectAdsl) self.assertIn('192.168.', str(pcaddr_disconnectAdsl), msg='PPPoE挂断失败') self.driver.quit() print('已过期账号 到期通告 - 验证成功') # 将期账号验证 # 开始拨号 Adsl.connect(self, name='adsl', username='******', password='******') # 通过断言IP地址网段,判断是否可以拨号成功 pcaddr_connectAdsl = socket.gethostbyname( socket.getfqdn(socket.gethostname())) # print(pcaddr_connectAdsl) self.assertIn('10.10.10.', str(pcaddr_connectAdsl), msg='PPPoE拨号失败') # 打开网页测试,测试上网 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 print(title1) self.assertEqual(title1, messages, msg='通告未显示') time.sleep(1) self.driver.get('http://www.baidu.com') time.sleep(2) title1 = self.driver.title print(title1) self.assertEqual(title1, baidutitle, msg='第二次打开网页异常') time.sleep(1) # 拨号挂断,通过断言IP地址网段,判断是否挂断 Adsl.disconnect(self) pcaddr_disconnectAdsl = socket.gethostbyname( socket.getfqdn(socket.gethostname())) print(pcaddr_disconnectAdsl) self.assertIn('192.168.', str(pcaddr_disconnectAdsl), msg='PPPoE挂断失败') self.driver.quit() print('将过期账号 到期通告 - 验证成功') print('账号到期通告 - 验证成功') #删除组织架构组(组内的pppoe账号也会一并删掉) organization_group.group_delete(self) # 关闭pppoe server login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) pppoeauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 pppoeauth.click_UserManage() time.sleep(0.5) pppoeauth.click_userAuth() time.sleep(1) pppoeauth.click_pppoeAuthC() time.sleep(1) # 断言 开启提示信息是否有误 status = str( pppoeauth.getAttribute_byXpath(pppoeauth.pppoeAuthCs, 'checked')) time.sleep(1) self.assertEqual(status, 'true', msg='PPPoE认证关闭出错') print('PPPoE认证关闭 验证成功') self.driver.quit() logger.info('test_003_AuthNotice passed')
def test_002_webAuthTest(self): u'''web认证测试''' if Support == '√': logger.info(u'参数支持本地认证') webauthpage = getAssertText('webauthpage') webauthsucess = getAssertText('webauthsucess') # 新增用户组及认证账号 # 调用新增组 “SelfComputerTest” organization_group.group_add(self) time.sleep(1) # login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) webauth = Organization_userAuthPage(self.driver, self.url) # 打开用户管理 - 用户认证 webauth.click_UserManage() time.sleep(0.5) webauth.click_userAuth() time.sleep(1) webauth.click_account() time.sleep(1) webauth.click_addUser() time.sleep(1) webauth.input_name('webtest1') # 仅有一个用户组,这里省略 select = webauth.selelement_byName(webauth.authType) Select(select).select_by_value('Web') time.sleep(1) webauth.input_authAccount('webtest1') webauth.input_authPassword('webtest1') webauth.click_save() time.sleep(2) # 断言 添加的账号 认证方式和认证账号 是否正常 list_authtype = webauth.getText_byXpath(webauth.list_authtype) list_authAcc = webauth.getText_byXpath(webauth.list_authAcc) self.assertEqual(str(list_authtype), 'Web', msg='认证方式显示不为“Web”') self.assertEqual(str(list_authAcc), 'webtest1', msg='认证账号不为“webtest1”') self.driver.quit() 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 print(title1) self.assertEqual(title1, webauthpage, msg='认证页面跳转不正常') webauth = Organization_userAuthPage(self.driver, self.url) webauth.input_userName('webtest1') webauth.input_userPasswd('webtest1') webauth.click_loginbtn() time.sleep(2) title2 = self.driver.title print(title2) self.assertEqual(title2, webauthsucess, msg='不能认证成功') 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_webAuthTest passed')