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_001_UserStatistics(self): u'''用户统计(某些型号不支持建立pppoe账号)''' tempUser = getAssertText('tempUser') Minute = getAssertText('minute') Ban = getAssertText('Ban') pppoeSp = getParameter('pppoeSp') SupportP = getExcelValue(pppoeSp) webAutnp = getParameter('webAutnp') SupportW = getExcelValue(webAutnp) userstatus = Organization_userStatusPage(self.driver, self.url) userstatus.click_userstatus() time.sleep(1) # 将页面刷新按钮改成“手动” selmanual = userstatus.selelement_byXpath(userstatus.selmanual) Select(selmanual).select_by_value('3') time.sleep(0.3) Select(selmanual).select_by_value('5') time.sleep(0.3) Select(selmanual).select_by_value('10') time.sleep(0.3) Select(selmanual).select_by_value('60') time.sleep(0.3) Select(selmanual).select_by_value('manual') time.sleep(0.3) userstatus.click_refreshtable() time.sleep(1) #右上角移动、加入黑名单按钮 userstatus.find_move() userstatus.find_addToBlackList() # 定义页面显示元素变量 ID = str(userstatus.getText_byXpath(userstatus.ID)) username = str(userstatus.getText_byXpath(userstatus.username)) group = str(userstatus.getText_byXpath(userstatus.group)) VlanID = str(userstatus.getText_byXpath(userstatus.VlanID)) IP = str(userstatus.getText_byXpath(userstatus.IP)) mac = str(userstatus.getText_byXpath(userstatus.mac)) authmode = str(userstatus.getText_byXpath(userstatus.authmode)) online_time_length = str( userstatus.getText_byXpath(userstatus.online_time_length)) Uploading_data = str( userstatus.getText_byXpath(userstatus.Uploading_data)) Downing_data = str(userstatus.getText_byXpath(userstatus.Downing_data)) Uploading_speed = str( userstatus.getText_byXpath(userstatus.Uploading_speed)) Downing_speed = str( userstatus.getText_byXpath(userstatus.Downing_speed)) edit = str(userstatus.getText_byXpath(userstatus.edit)) # 断言 用户列表是否显示有误 time.sleep(1) self.assertEqual(ID, '1', msg='ID出错') print('用户状态 - ID 验证成功') self.assertIsNotNone(username, msg='用户名 出错') print('用户状态 - 用户名 验证成功') self.assertEqual(group, tempUser, msg='所属组 出错') # 脚本在最后会清空组织架构,所以脚本在一开始新建组,用户都是 临时用户 print('用户状态 - 所属组 验证成功') self.assertIsNotNone(VlanID, msg='VLANID 出错') print('用户状态 - VLANID 验证成功') self.assertIn('192.168.', IP, msg='IP 出错') # lan口地址段 print('用户状态 - IP 验证成功') self.assertEqual(len(mac), 17, msg='mac 出错') # 判断mac地址长度 print('用户状态 - mac 验证成功') self.assertIsNotNone(authmode, msg='认证方式 出错') print('用户状态 - 认证方式 验证成功') self.assertIn(Minute, online_time_length, msg='在线时长 出错') # 在线时长是否包含“分” print('用户状态 - 在线时长 验证成功') self.assertIsNotNone(Uploading_data, msg='上传数据 出错') print('用户状态 - 上传数据 验证成功') self.assertIsNotNone(Downing_data, msg='下载数据 出错') print('用户状态 - 下载数据 验证成功') self.assertIsNotNone(Uploading_speed, msg='上传速度 出错') print('用户状态 - 上传速度 验证成功') self.assertIsNotNone(Downing_speed, msg='下载速度 出错') print('用户状态 - 下载速度 验证成功') self.assertEqual(edit, Ban, msg='拉黑菜单显示 出错') print('用户状态 - 拉黑菜单显示 验证成功') userauth = Organization_userAuthPage(self.driver, self.url) userauth.click_userAuth() time.sleep(1) userauth.click_account() time.sleep(2) userauth.click_addUser() time.sleep(1) selauthType = userauth.selelement_byName(userauth.authType) if SupportW == '√': try: self.driver.implicitly_wait(2) Select(selauthType).select_by_value('Web') except NoSuchElementException: raise Exception('认证账号中不能选择web类型') elif SupportW == '×': try: self.driver.implicitly_wait(2) Select(selauthType).select_by_value('Web') except NoSuchElementException: logger.info(u'认证账号中不能选择web类型,与参数表相符') else: CapPic(self.driver) logger.info(u'认证账号中能选择web类型,与参数表不相符') raise Exception('认证账号中能选择web类型,与参数表不相符') else: logger.info(u'web参数表读取异常') logger.info(u'web参数表读取值为:', SupportW) raise Exception(u'web参数表读取异常') time.sleep(0.3) if SupportP != '×': try: self.driver.implicitly_wait(2) Select(selauthType).select_by_value('PPPoE') except NoSuchElementException: raise Exception('认证账号中不能选择pppoe类型') elif SupportP == '×': try: self.driver.implicitly_wait(2) Select(selauthType).select_by_value('PPPoE') except NoSuchElementException: logger.info(u'认证账号中不能选择pppoe类型,与参数表相符') else: CapPic(self.driver) logger.info(u'认证账号中能选择pppoe类型,与参数表不相符') raise Exception('认证账号中能选择pppoe类型,与参数表不相符') else: logger.info(u'pppoe参数表读取异常') logger.info(u'pppoe参数表读取值为:', SupportP) raise Exception(u'pppoe参数表读取异常') time.sleep(0.3) self.driver.implicitly_wait(10) self.driver.quit() logger.info('test_001_UserStatistics passed')
def test_004_WEBAuth(self): u'''本地认证(某些设备可能不支持)''' webAutnp = getParameter('webAutnp') Support = getExcelValue(webAutnp) webauth = Organization_userAuthPage(self.driver, self.url) webauth.click_userAuth() time.sleep(1) if Support == '√': logger.info(u'参数支持本地认证') try: self.driver.implicitly_wait(2) webauth.click_WebConfig() except AttributeError or NoSuchElementException: CapPic(self.driver) logger.info(u'软件不支持本地认证,与参数表不符') raise Exception(u'软件不支持本地认证,与参数表不符') else: logger.info(u'软件支持本地认证,与参数表相符') self.driver.implicitly_wait(10) time.sleep(1) #认证页面 webauth.click_modaifyAuthPage() time.sleep(1) webauth.input_webAuthSuccessNote('test') webauth.selelement_byName(webauth.en_picture) webauth.click_activePicEn() time.sleep(0.5) webauth.click_activePicC() time.sleep(0.5) webauth.input_tipstitle('test') webauth.input_tipsinfo('test') webauth.input_hidcontact('test') webauth.click_close_webauth() time.sleep(0.5) webauth.input_staleTime('5') webauth.click_selfenabled() time.sleep(0.2) webauth.click_modalhide() time.sleep(0.5) webauth.click_account() time.sleep(1) webauth.click_addUser() time.sleep(1) selauthType = webauth.selelement_byName(webauth.authType) Select(selauthType).select_by_value('Web') time.sleep(0.3) # 并发数 webauth.input_concurrency('10') # 计费 webauth.click_accountBillEn() time.sleep(0.3) selbillType = webauth.selelement_byName(webauth.billType) Select(selbillType).select_by_value('timeBill') time.sleep(0.3) Select(selbillType).select_by_value('dateBill') time.sleep(0.3) webauth.click_accountBillC() time.sleep(0.3) elif Support == '×': logger.info(u'参数不支持本地认证') try: self.driver.implicitly_wait(2) webauth.click_WebConfig() except AttributeError or NoSuchElementException: logger.info(u'软件不支持web认证,与参数表相符') else: CapPic(self.driver) logger.info(u'软件支持web认证,与参数表不符') raise Exception(u'软件支持web认证,与参数表不符') else: logger.info(u'参数表读取异常') logger.info(u'参数表读取值为:', Support) raise Exception(u'参数表读取异常') self.driver.quit() logger.info('test_004_WEBAuth passed')
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')
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')