def test_003_PPPoESever(self): u'''PPPoE-Sever拨号用户(某些设备可能不支持)''' pppoeSp = getParameter('pppoeSp') Support = getExcelValue(pppoeSp) pppoeauth = Organization_userAuthPage(self.driver, self.url) pppoeauth.click_userAuth() time.sleep(1) if Support != '×': logger.info(u'参数支持PPPoE-Sever') try: self.driver.implicitly_wait(2) pppoeauth.click_PPPoEConfig() except AttributeError or NoSuchElementException: CapPic(self.driver) logger.info(u'软件不支持PPPoE Server,与参数表不符') raise Exception(u'软件不支持PPPoE Server,与参数表不符') else: logger.info(u'软件支持PPPoE Server,与参数表相符') self.driver.implicitly_wait(10) time.sleep(1) pppoeauth.click_PPPoEOnly() pppoeauth.find_selexceptIpGroup() pppoeauth.input_smaxconv('100') pppoeauth.click_selfHelpEnable() pppoeauth.click_PppoeNoticeEn() pppoeauth.input_remainDays('50') pppoeauth.click_edipage() time.sleep(1) pppoeauth.click_NoticePageName() pppoeauth.input_NoticePageNote('test') pppoeauth.input_NoticePageTitle('test') pppoeauth.input_SkipUrl('test') pppoeauth.input_SkipTime('5') pppoeauth.input_NoticeBody('test') pppoeauth.click_close() #关闭 time.sleep(0.5) pppoeauth.click_modalhide() time.sleep(0.5) pppoeauth.click_account() time.sleep(1) pppoeauth.click_addUser() time.sleep(1) #并发数 pppoeauth.input_concurrency('10') #绑定方式 pppoeauth.click_addautoBind() pppoeauth.click_IPBind() pppoeauth.click_MacBind() pppoeauth.click_IPMacBind() pppoeauth.click_noBind() #账号计费 pppoeauth.click_accountBillEn() pppoeauth.click_accountBillC() elif Support == '×': logger.info(u'参数不支持PPPoE-Sever') try: self.driver.implicitly_wait(2) pppoeauth.click_PPPoEConfig() except AttributeError or NoSuchElementException: logger.info(u'软件不支持PPPoE,与参数表相符') else: CapPic(self.driver) logger.info(u'软件支持PPPoE,与参数表不符') raise Exception(u'软件支持PPPoE,与参数表不符') else: logger.info(u'参数表读取异常') logger.info(u'参数表读取值为:', Support) raise Exception(u'参数表读取异常') self.driver.quit() logger.info('test_003_PPPoESever 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')