示例#1
0
 def setUp(self):
     logger.info('setUp start')
     login.loginWeb(self)  # admin账号登录
     self.driver.implicitly_wait(10)
     wanpage = NetworkConfig_wanpage(self.driver,self.url)
     wanpage.click_NetworkConfig()
     time.sleep(0.5)
     wanpage.click_WANconfig()
     time.sleep(1)
     wanpage.click_GlobalConfig()
     time.sleep(1)
示例#2
0
 def test_000_getReady(self):
     u'''更改wan口数量 以及设置wan2与上联口互通'''
     wan_config = NetworkConfig_wanpage(self.driver, self.url)
     #1、 动态wan口,调整wan口数量
     wan_config.click_GlobalConfig()
     time.sleep(1)
     try:
         self.driver.implicitly_wait(2)
         wan_config.find_PortNumber()
     except ElementNotVisibleException:
         logger.info(u'页面没有wan口数量调整,不支持动态WAN口')
     except ElementNotInteractableException:
         logger.info(u'页面没有wan口数量调整,不支持动态WAN口')
     else:
         selPortNumber = wan_config.selelement_byName(
             wan_config.selPortNumber)
         Select(selPortNumber).select_by_value('2')
         time.sleep(2)
         try:
             wan_config.find_cfm_ok()
         except NoSuchElementException:
             logger.info(u'WAN口数量已为2')
         else:
             time.sleep(30)
             i = 0
             while i < 20:
                 now_url = str(self.driver.current_url)
                 # print(now_url,i)
                 if '/noAuth/login.html' not in now_url:  # 如果不同
                     time.sleep(5)
                 else:
                     break
                 i += 1
             else:
                 raise Exception('更改设备wan口数量后未正常启动')
     self.driver.quit()
     #2 调整wan2 与上联口互通
     swconfig.test_changeWAN2(self)
     logger.info('test_000_getReady passed')
示例#3
0
    def test_003_5PPPoE(self):
        u'''五条线路PPPOE拨入'''
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        ConnectState = getAssertText('ConnectState')
        # WAN1改成pppoe
        wan_config.click_line1edit()
        time.sleep(1)
        access_mode = wan_config.selelement_byName(wan_config.connectionType)
        Select(access_mode).select_by_value('PPPOE')
        time.sleep(1)
        wan_config.input_pppoeUser('111')
        wan_config.input_pppoePass('111')
        wan_config.click_save()
        time.sleep(10)
        self.driver.quit()  # 修改接口后 可能会回到登录页面 所以关闭,再打开
        # WAN2口改为pppoe接入
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        # 进入网络配置-外网配置
        wan_config.click_NetworkConfig()
        time.sleep(0.5)
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_line2edit()
        time.sleep(1)
        access_mode = wan_config.selelement_byName(wan_config.connectionType)
        Select(access_mode).select_by_value('PPPOE')
        time.sleep(1)
        wan_config.input_pppoeUser('222')  # 输入上层网关配置的PPPoE账号密码
        wan_config.input_pppoePass('222')
        wan_config.click_save()
        time.sleep(10)
        self.driver.quit()  # 修改接口后 可能会回到登录页面 所以关闭,再打开
        # WAN3口改为pppoe接入
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        # 进入网络配置-外网配置
        wan_config.click_NetworkConfig()
        time.sleep(0.5)
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_line3edit()
        time.sleep(1)
        access_mode = wan_config.selelement_byName(wan_config.connectionType)
        Select(access_mode).select_by_value('PPPOE')
        time.sleep(1)
        wan_config.input_pppoeUser('333')  # 输入上层网关配置的PPPoE账号密码
        wan_config.input_pppoePass('333')
        wan_config.click_save()
        time.sleep(10)
        self.driver.quit()  # 修改接口后 可能会回到登录页面 所以关闭,再打开
        # WAN4口改为pppoe接入
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        # 进入网络配置-外网配置
        wan_config.click_NetworkConfig()
        time.sleep(0.5)
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_line4edit()
        time.sleep(1)
        access_mode = wan_config.selelement_byName(wan_config.connectionType)
        Select(access_mode).select_by_value('PPPOE')
        time.sleep(1)
        wan_config.input_pppoeUser('444')  # 输入上层网关配置的PPPoE账号密码
        wan_config.input_pppoePass('444')
        wan_config.click_save()
        time.sleep(10)
        self.driver.quit()  # 修改接口后 可能会回到登录页面 所以关闭,再打开
        # WAN4口改为pppoe接入
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        # 进入网络配置-外网配置
        wan_config.click_NetworkConfig()
        time.sleep(0.5)
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_line5edit()
        time.sleep(1)
        access_mode = wan_config.selelement_byName(wan_config.connectionType)
        Select(access_mode).select_by_value('PPPOE')
        time.sleep(1)
        wan_config.input_pppoeUser('555')  # 输入上层网关配置的PPPoE账号密码
        wan_config.input_pppoePass('555')
        wan_config.click_save()
        time.sleep(10)
        self.driver.quit()  # 修改接口后 可能会回到登录页面 所以关闭,再打开

        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        # 进入网络配置-外网配置
        wan_config.click_NetworkConfig()
        time.sleep(0.5)
        wan_config.click_WANconfig()
        time.sleep(1)
        # 断言
        n = 0
        while n < 30:
            wan_config.click_refresh()
            time.sleep(1)
            list_connectState1 = wan_config.getText_byXpath(wan_config.connectState1)
            list_connectState2 = wan_config.getText_byXpath(wan_config.connectState2)
            list_connectState3 = wan_config.getText_byXpath(wan_config.connectState3)
            list_connectState4 = wan_config.getText_byXpath(wan_config.connectState4)
            list_connectState5 = wan_config.getText_byXpath(wan_config.connectState5)
            print(str(list_connectState1), str(list_connectState2), str(list_connectState3), str(list_connectState4),
                  str(list_connectState5))
            list_connectState = [str(list_connectState1), str(list_connectState2), str(list_connectState3),
                                 str(list_connectState4), str(list_connectState5)]
            # 动态接入 未获取到地址/wan口线未接入 都是未连接
            if all(t == ConnectState for t in list_connectState):
                print('WAN口均已连接', n)
                break
            else:
                time.sleep(2)
                n += 1
        else:
            raise Exception('WAN口未连接')
        time.sleep(2)

        # 获取两个wan口IP、mac,pppoe接口通过IP判断接口名,固定通过mac地址判断接口名
        line1_ip = str(wan_config.getText_byXpath(wan_config.line1IP))
        # print('line1_ip:', line1_ip)
        line2_ip = str(wan_config.getText_byXpath(wan_config.line2IP))
        # print('line2_ip:', line2_ip)
        line3_ip = str(wan_config.getText_byXpath(wan_config.line3IP))
        line4_ip = str(wan_config.getText_byXpath(wan_config.line4IP))
        line5_ip = str(wan_config.getText_byXpath(wan_config.line5IP))
        time.sleep(3)
        # telnet获取接口名称及确认默认路由
        # 获取接口名称
        hostip = gettelnet('host')
        port = gettelnet('port')
        username = bytes(getweb('User'), encoding="utf8")
        password = bytes(getweb('Passwd'), encoding="utf8")
        tn = telnetlib.Telnet(host=hostip, port=port,timeout=10)
        tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
        tn.read_until(b'login:'******'Password:'******'ip route' + b'\n')
        # 输出结果,判断
        time.sleep(1)
        result = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
        print('-------------------输出结果------------------------')
        # 命令执行结果
        print('result:', result)
        # 获取WAN1对应接口名称
        result1 = result[2:-7]
        print('result1', result1)
        result2 = result1.split(r'\r\n')
        print('result2', result2)

        for x in range(len(result2)):
            if line1_ip in result2[x]:
                result2_num1 = (result2[x])
                print(result2_num1)
                line1_Interface_name = result2_num1.split()[2]
                print(line1_Interface_name)
            if line2_ip in result2[x]:
                result2_num1 = (result2[x])
                print(result2_num1)
                line2_Interface_name = result2_num1.split()[2]
                print(line2_Interface_name)
            if line3_ip in result2[x]:
                result2_num1 = (result2[x])
                print(result2_num1)
                line3_Interface_name = result2_num1.split()[2]
                print(line3_Interface_name)
            if line4_ip in result2[x]:
                result2_num1 = (result2[x])
                print(result2_num1)
                line4_Interface_name = result2_num1.split()[2]
                print(line4_Interface_name)
            if line5_ip in result2[x]:
                result2_num1 = (result2[x])
                print(result2_num1)
                line5_Interface_name = result2_num1.split()[2]
                print(line5_Interface_name)
        if line1_Interface_name == None:
            raise Exception('获取wan1口对应接口名称失败')
        if line2_Interface_name == None:
            raise Exception('获取wan2口对应接口名称失败')
        if line3_Interface_name == None:
            raise Exception('获取wan3口对应接口名称失败')
        if line4_Interface_name == None:
            raise Exception('获取wan4口对应接口名称失败')
        if line5_Interface_name == None:
            raise Exception('获取wan5口对应接口名称失败')

        # 确认默认路由情况
        wan1route = 'nexthop dev ' + line1_Interface_name + ' weight '
        wan2route = 'nexthop dev ' + line2_Interface_name + ' weight '
        wan3route = 'nexthop dev ' + line3_Interface_name + ' weight '
        wan4route = 'nexthop dev ' + line4_Interface_name + ' weight '
        wan5route = 'nexthop dev ' + line5_Interface_name + ' weight '
        print('wan1route:', wan1route, 'wan2route:', wan2route, 'wan3route:', wan3route, 'wan4route:', wan4route,
              'wan5route:', wan5route)

        for i in range(len(result2)):
            if wan1route in result2[i]:
                wan1route_status = not None
                print('wan1路由在')
            if wan2route in result2[i]:
                wan2route_status = not None
                print('wan2路由在')
            if wan3route in result2[i]:
                wan3route_status = not None
                print('wan3路由在')
            if wan4route in result2[i]:
                wan4route_status = not None
                print('wan4路由在')
            if wan5route in result2[i]:
                wan5route_status = not None
                print('wan5路由在')
        if wan1route_status == None:
            raise Exception('wan1默认路由不存在')
        if wan2route_status == None:
            raise Exception('wan2默认路由不存在')
        if wan3route_status == None:
            raise Exception('wan3默认路由不存在')
        if wan4route_status == None:
            raise Exception('wan4默认路由不存在')
        if wan5route_status == None:
            raise Exception('wan5默认路由不存在')

        tn.close()  # tn.write('exit\n')

        logger.info(u'五条线路PPPOE拨入 验证通过')

        # 取消线路检测
        wan_config.click_GlobalConfig()
        time.sleep(1)
        wan_config.input_KeepLive1('0')
        wan_config.input_KeepLive2('0')
        wan_config.input_KeepLive3('0')
        wan_config.input_KeepLive4('0')
        wan_config.input_KeepLive5('0')
        wan_config.click_save()
        # 等待弹窗提示成功
        i = 0
        while i < 80:
            try:
                self.driver.implicitly_wait(1)
                wan_config.find_tipsshowin()
            except NoSuchElementException:
                time.sleep(1)
                i = i + 1
                print(i)
            else:
                tips = str(wan_config.getAttribute_byClass(wan_config.tipsshowin, 'tip-sign'))
                print(tips, i)
                if tips != 'success':
                    CapPic(self.driver)
                    logger.info(u'线路检测保存 异常')
                    raise Exception(u'线路检测保存 异常')
                break
        else:
            raise Exception(u'线路检测保存 未弹出提示框')
        # 切换标签页判断配置正确
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_GlobalConfig()
        time.sleep(1)
        KeepLive1 = str(wan_config.getAttribute_byName(wan_config.KeepLive1v, 'value'))
        KeepLive2 = str(wan_config.getAttribute_byName(wan_config.KeepLive2v, 'value'))
        KeepLive3 = str(wan_config.getAttribute_byName(wan_config.KeepLive3v, 'value'))
        KeepLive4 = str(wan_config.getAttribute_byName(wan_config.KeepLive4v, 'value'))
        KeepLive5 = str(wan_config.getAttribute_byName(wan_config.KeepLive5v, 'value'))
        self.assertEqual(KeepLive1, '0', msg='wan1检测间隔不为0')
        self.assertEqual(KeepLive2, '0', msg='wan2检测间隔不为0')
        self.assertEqual(KeepLive3, '0', msg='wan3检测间隔不为0')
        self.assertEqual(KeepLive4, '0', msg='wan4检测间隔不为0')
        self.assertEqual(KeepLive5, '0', msg='wan5检测间隔不为0')
        # wan1改回动态接入,得到正确的IP地址及网关地址
        wan_config.click_WANconfig()
        time.sleep(1)
        # WAN1
        wan_config.click_line1edit()
        time.sleep(1)
        access_mode = wan_config.selelement_byName(wan_config.connectionType)
        Select(access_mode).select_by_value('DHCP')
        wan_config.click_save()
        time.sleep(10)
        self.driver.quit()
        logger.info('test_003_5PPPoE passed')
示例#4
0
    def test_002_staticSW(self):
        u'''五条线路固定接入线路切换'''
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        # 1、获取wan mac
        line1_mac = str(wan_config.getText_byXpath(wan_config.line1Mac))
        line2_mac = str(wan_config.getText_byXpath(wan_config.line2Mac))
        line3_mac = str(wan_config.getText_byXpath(wan_config.line3Mac))
        line4_mac = str(wan_config.getText_byXpath(wan_config.line4Mac))
        line5_mac = str(wan_config.getText_byXpath(wan_config.line5Mac))
        # 处理wan口的mac地址
        # 字母变大写
        line1_mac1 = line1_mac.upper()
        line2_mac1 = line2_mac.upper()
        line3_mac1 = line3_mac.upper()
        line4_mac1 = line4_mac.upper()
        line5_mac1 = line5_mac.upper()
        # 加冒号
        line1_mac2 = line1_mac1[0:2] + ':' + line1_mac1[2:4] + ':' + line1_mac1[4:6] + ':' + line1_mac1[
                                                                                             6:8] + ':' + line1_mac1[
                                                                                                          8:10] + ':' + line1_mac1[
                                                                                                                        10:]
        line2_mac2 = line2_mac1[0:2] + ':' + line2_mac1[2:4] + ':' + line2_mac1[4:6] + ':' + line2_mac1[
                                                                                             6:8] + ':' + line2_mac1[
                                                                                                          8:10] + ':' + line2_mac1[
                                                                                                                        10:]
        line3_mac2 = line3_mac1[0:2] + ':' + line3_mac1[2:4] + ':' + line3_mac1[4:6] + ':' + line3_mac1[
                                                                                             6:8] + ':' + line3_mac1[
                                                                                                          8:10] + ':' + line3_mac1[
                                                                                                                        10:]
        line4_mac2 = line4_mac1[0:2] + ':' + line4_mac1[2:4] + ':' + line4_mac1[4:6] + ':' + line4_mac1[
                                                                                             6:8] + ':' + line4_mac1[
                                                                                                          8:10] + ':' + line4_mac1[
                                                                                                                        10:]
        line5_mac2 = line5_mac1[0:2] + ':' + line5_mac1[2:4] + ':' + line5_mac1[4:6] + ':' + line5_mac1[
                                                                                             6:8] + ':' + line5_mac1[
                                                                                                          8:10] + ':' + line5_mac1[
                                                                                                                        10:]
        print('line1_mac2:', line1_mac2, 'line2_mac2:', line2_mac2, 'line3_mac2:', line3_mac2, 'line4_mac2:',
              line4_mac2, 'line5_mac2:', line5_mac2)
        self.driver.quit()
        # 2、设置线路检测地址,验证线路切换
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        # 进入网络配置-外网配置
        wan_config.click_NetworkConfig()
        time.sleep(0.5)
        wan_config.click_WANconfig()
        time.sleep(1)
        # 配置线路检测 检测3s 检测 3次,地址为223.5.5.5
        wan_config.click_GlobalConfig()
        time.sleep(1)
        wan_config.input_KeepLive1('3')
        wan_config.input_RetryTimes1('3')
        sel1 = wan_config.selelement_byName(wan_config.PriAddrType1)
        Select(sel1).select_by_value('others')
        time.sleep(0.5)
        wan_config.input_DestIP1('223.5.5.5')

        wan_config.input_KeepLive2('3')
        wan_config.input_RetryTimes2('3')
        sel2 = wan_config.selelement_byName(wan_config.PriAddrType2)
        Select(sel2).select_by_value('others')
        time.sleep(0.5)
        wan_config.input_DestIP2('1.2.3.4')  # WAN2配一个ping不通的地址,测试线路切换

        wan_config.input_KeepLive3('3')
        wan_config.input_RetryTimes3('3')
        sel3 = wan_config.selelement_byName(wan_config.PriAddrType3)
        Select(sel3).select_by_value('others')
        time.sleep(0.5)
        wan_config.input_DestIP3('1.2.3.5')  # WAN3配一个ping不通的地址,测试线路切换

        wan_config.input_KeepLive4('3')
        wan_config.input_RetryTimes4('3')
        sel4 = wan_config.selelement_byName(wan_config.PriAddrType4)
        Select(sel4).select_by_value('others')
        time.sleep(0.5)
        wan_config.input_DestIP4('1.2.3.6')  # WAN4配一个ping不通的地址,测试线路切换

        wan_config.input_KeepLive5('3')
        wan_config.input_RetryTimes5('3')
        sel5 = wan_config.selelement_byName(wan_config.PriAddrType5)
        Select(sel5).select_by_value('others')
        time.sleep(0.5)
        wan_config.input_DestIP5('1.2.3.7')  # WAN5配一个ping不通的地址,测试线路切换
        wan_config.click_save()
        # 等待弹窗提示成功
        i = 0
        while i < 80:
            try:
                self.driver.implicitly_wait(1)
                wan_config.find_tipsshowin()
            except NoSuchElementException:
                time.sleep(1)
                i = i + 1
                print(i)
            else:
                tips = str(wan_config.getAttribute_byClass(wan_config.tipsshowin, 'tip-sign'))
                print(tips, i)
                if tips != 'success':
                    CapPic(self.driver)
                    logger.info(u'线路检测保存 异常')
                    raise Exception(u'线路检测保存 异常')
                break
        else:
            raise Exception(u'线路检测保存 未弹出提示框')
        # 切换标签页判断配置正确
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_GlobalConfig()
        time.sleep(1)
        KeepLive5 = str(self.driver.find_element_by_name('KeepLive5').get_attribute('value'))
        RetryTimes5 = str(self.driver.find_element_by_name('RetryTimes5').get_attribute('value'))
        DestIP5 = str(self.driver.find_element_by_name('DestIP5').get_attribute('value'))
        self.assertEqual(KeepLive5, '3', msg='wan5检测间隔与设置不一致')
        self.assertEqual(RetryTimes5, '3', msg='wan5检测次数与设置不一致')
        self.assertEqual(DestIP5, '1.2.3.7', msg='wan5检测地址与设置不一致')

        # telnet获取接口名称及确认默认路由(wan2/wan3检测不通,应只剩下wan1默认路由)
        # 获取接口名称
        hostip = gettelnet('host')
        port = gettelnet('port')
        username = bytes(getweb('User'), encoding="utf8")
        password = bytes(getweb('Passwd'), encoding="utf8")
        tn = telnetlib.Telnet(host=hostip, port=port,timeout=10)
        tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
        tn.read_until(b'login:'******'Password:'******'#')
        tn.write(b'ifconfig | grep eth' + b'\n')
        # 输出结果,判断
        time.sleep(1)
        result = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
        print('-------------------输出结果------------------------')
        # 命令执行结果
        print('result:', result)
        # 获取WAN口对应接口名称
        result1 = result[3:-9]
        # print(result1)
        result2 = result1.split(r'\r\n')
        print('result2:', result2)

        for i in range(len(result2)):
            if line1_mac2 in result2[i]:
                result2_num = (result2[i])
                print(result2[i])
                line1_Interface_name = result2_num.split()[0]
                print(line1_Interface_name)
            if line2_mac2 in result2[i]:
                result2_num = (result2[i])
                print(result2[i])
                line2_Interface_name = result2_num.split()[0]
                print(line2_Interface_name)
            if line3_mac2 in result2[i]:
                result2_num = (result2[i])
                print(result2[i])
                line3_Interface_name = result2_num.split()[0]
                print(line3_Interface_name)
            if line4_mac2 in result2[i]:
                result2_num = (result2[i])
                print(result2[i])
                line4_Interface_name = result2_num.split()[0]
                print(line4_Interface_name)
            if line5_mac2 in result2[i]:
                result2_num = (result2[i])
                print(result2[i])
                line5_Interface_name = result2_num.split()[0]
                print(line5_Interface_name)
        if line1_Interface_name == None:
            raise Exception('获取wan1口对应接口名称失败')
        if line2_Interface_name == None:
            raise Exception('获取wan2口对应接口名称失败')
        if line3_Interface_name == None:
            raise Exception('获取wan3口对应接口名称失败')
        if line4_Interface_name == None:
            raise Exception('获取wan4口对应接口名称失败')
        if line5_Interface_name == None:
            raise Exception('获取wan5口对应接口名称失败')

        time.sleep(10)  # 等待检测,路由切换
        # 确认默认路由情况
        # 单线路默认路由变为:default via 192.168.11.1 dev eth2.2 equalize 不再有weight值
        wan1route1 = 'dev ' + line1_Interface_name
        print('wan1route:', wan1route1)
        roure1 = bytes(('ip route | grep "%s"') % line1_Interface_name, encoding="utf8")
        x = 0
        while x < 60:
            tn = telnetlib.Telnet(host=hostip, port=port,timeout=10)
            tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
            tn.read_until(b'login:'******'Password:'******'#')
            tn.write(roure1 + b'\n')
            # 输出结果,判断
            time.sleep(1)
            result = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            # print('result:', result)
            result4 = result[1:]
            # print('result4', result4)
            result5 = result4.replace('\r\n', ' ')
            # print('result5', result5)
            tn.close()
            # wan2、wan3检测不通,这里只判断wan1的
            if 'default' in result5 and wan1route1 in result5:
                print('wan1路由在')
                break
            else:
                print(x)
                time.sleep(2)
                x += 1
        else:
            logger.info(u'wan1route1: %s' % wan1route1)
            logger.info(u'result5: %s' % result5)
            raise Exception('wan1默认路由显示有误')

        # 3、将wan2\wan3检测目标改正确,线路、路由切换回来
        wan_config.input_DestIP2('223.5.5.5')  # WAN2检测地址改可ping通,测试线路切换
        wan_config.input_DestIP3('223.5.5.5')  # WAN3检测地址改可ping通,测试线路切换
        wan_config.input_DestIP4('223.5.5.5')  # WAN4检测地址改可ping通,测试线路切换
        wan_config.input_DestIP5('223.5.5.5')  # WAN5检测地址改可ping通,测试线路切换
        wan_config.click_save()
        # 等待弹窗提示成功
        i = 0
        while i < 80:
            try:
                self.driver.implicitly_wait(1)
                wan_config.find_tipsshowin()
            except NoSuchElementException:
                time.sleep(1)
                i = i + 1
                print(i)
            else:
                tips = str(wan_config.getAttribute_byClass(wan_config.tipsshowin, 'tip-sign'))
                print(tips, i)
                if tips != 'success':
                    CapPic(self.driver)
                    logger.info(u'线路检测保存 异常')
                    raise Exception(u'线路检测保存 异常')
                break
        else:
            raise Exception(u'线路检测保存 未弹出提示框')
        # 切换标签页判断配置正确
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_GlobalConfig()
        time.sleep(1)
        DestIP5 = str(wan_config.getAttribute_byName(wan_config.DestIP5v, 'value'))
        self.assertEqual(DestIP5, '223.5.5.5', msg='wan5检测地址与设置不一致')

        # telnet获取接口名称及确认默认路由 检测通应该恢复5条默认路由
        wan1route_2 = 'dev ' + line1_Interface_name + ' weight '
        wan2route_2 = 'dev ' + line2_Interface_name + ' weight '
        wan3route_2 = 'dev ' + line3_Interface_name + ' weight '
        wan4route_2 = 'dev ' + line3_Interface_name + ' weight '
        wan5route_2 = 'dev ' + line3_Interface_name + ' weight '
        print('wan1route_2:', wan1route_2, 'wan2route_2:', wan2route_2, 'wan3route_2:', wan3route_2, 'wan4route_2:',
              wan4route_2, 'wan5route_2:', wan5route_2)
        time.sleep(10)  # 等待检测,路由切换
        # 获取接口名称
        x = 0
        while x < 60:
            tn = telnetlib.Telnet(host=hostip, port=port,timeout=10)
            tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
            tn.read_until(b'login:'******'Password:'******'#')
            # 确认默认路由情况
            tn.write(b'ip route' + b'\n')
            # 输出结果,判断
            time.sleep(1)
            result9 = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            # print('result9:', result9)
            result10 = result9[1:]
            # print('result10', result10)
            result11 = result10.replace('\r\n',' ')
            # print('result11', result11)
            tn.close()
            if (wan1route_2 in result11) and (wan2route_2 in result11) and (wan3route_2 in result11) and (
                    wan4route_2 in result11) and (wan5route_2 in result11):
                print('wan1/wan2/wan3/wan4/wan5路由在')
                break
            else:
                print(x)
                time.sleep(2)
                x += 1
        else:
            logger.info(u'wan1route_2: %s' % wan1route_2)
            logger.info(u'wan2route_2: %s' % wan2route_2)
            logger.info(u'wan3route_2: %s' % wan3route_2)
            logger.info(u'wan4route_2: %s' % wan4route_4)
            logger.info(u'wan5route_2: %s' % wan5route_4)
            logger.info(u'result11 %s' % result11)
            raise Exception('wan1/wan2/wan3/wan4/wan5默认路由显示有误')

        tn.close()  # tn.write('exit\n')
        self.driver.quit()
        logger.info('test_002_staticSW passed')
    def test_004_Fastforward(self):
        u'''硬件转发/软件转发 '''
        wanpage = NetworkConfig_wanpage(self.driver, self.url)
        wanpage.click_NetworkConfig()
        time.sleep(0.5)
        wanpage.click_WANconfig()
        time.sleep(1)
        wanpage.click_GlobalConfig()
        time.sleep(1)

        if hwNatP == '√':
            logger.info(u'参数支持硬件快速转发')
            try:
                self.driver.implicitly_wait(2)
                # 默认自动模式
                wanpage.click_FastForwardEnableC()
                wanpage.click_FastForwardModeC()
            except AttributeError:
                CapPic(self.driver)
                logger.info(u'不支持硬件快速转发,与参数表不相符')
                raise Exception('不支持硬件快速转发,与参数表不相符')
            else:
                enable1 = wanpage.getAttribute_byXpath(wanpage.enable1,
                                                       'selected')
                enable2 = wanpage.getAttribute_byXpath(wanpage.enable2,
                                                       'selected')
                # print('enable1:', enable1,'enable2:', enable2,)
                if enable1 != 'true':
                    logger.info(u'快速转发模式开关默认不为自动')
                    CapPic(self.driver)
                    raise Exception(u'快速转发模式开关默认不为自动')
                if enable2 != 'true':
                    logger.info(u'模式开关默认不为硬件转发')
                    CapPic(self.driver)
                    raise Exception(u'模式开关默认不为硬件转发')
                FastForwardEnable = wanpage.selelement_byName(
                    'FastForwardEnable')
                Select(FastForwardEnable).select_by_value('NatOpen')
                time.sleep(0.3)
                Select(FastForwardEnable).select_by_value('0')
                time.sleep(0.3)
                Select(FastForwardEnable).select_by_value('NatAuto')
                time.sleep(0.3)
                FastForwardMode = wanpage.selelement_byName('FastForwardMode')
                Select(FastForwardMode).select_by_value('sfNat')
                time.sleep(0.3)
                Select(FastForwardMode).select_by_value('hwNat')
        elif hwNatP == '×':
            logger.info(u'参数不支持硬件快速转发')
            try:
                self.driver.implicitly_wait(2)
                wanpage.click_FastForwardModeC()
            except AttributeError:
                logger.info('不支持硬件快速转,与参数表相符')
            else:
                CapPic(self.driver)
                logger.info(u'支持硬件快速转,与参数表不相符')
                raise Exception('支持硬件快速转,与参数表不相符')
        else:
            logger.info(u'参数表读取异常')
            logger.info(u'参数表读取值为:', hwNatP)
            raise Exception(u'参数表读取异常')

        if hwNatP == '×' and sfnatP == '√':
            logger.info(u'参数支持软件快速转发')
            try:
                self.driver.implicitly_wait(2)
                # 默认自动模式
                wanpage.click_FastForwardEnableC()
            except AttributeError:
                CapPic(self.driver)
                logger.info(u'不支持软件快速转发,与参数表不相符')
                raise Exception('不支持软件快速转发,与参数表不相符')
            else:
                enable1 = wanpage.getAttribute_byXpath(wanpage.enable1,
                                                       'selected')
                # print('enable1:', enable1)
                if enable1 != 'true':
                    logger.info(u'快速转发模式开关默认不为自动')
                    CapPic(self.driver)
                    raise Exception(u'快速转发模式开关默认不为自动')
                FastForwardEnable = wanpage.selelement_byName(
                    'FastForwardEnable')
                Select(FastForwardEnable).select_by_value('NatOpen')
                time.sleep(0.3)
                Select(FastForwardEnable).select_by_value('0')
                time.sleep(0.3)
                Select(FastForwardEnable).select_by_value('NatAuto')
        elif sfnatP == '×':
            logger.info(u'参数不支持软件快速转发')
            try:
                self.driver.implicitly_wait(2)
                wanpage.click_FastForwardEnableC()
            except AttributeError:
                logger.info('不支持软件快速转,与参数表相符')
            else:
                CapPic(self.driver)
                logger.info(u'支持软件快速转,与参数表不相符')
                raise Exception('支持软件快速转,与参数表不相符')
        self.driver.quit()
        logger.info('test_004_Fastforward passed')
示例#6
0
    def test_004_PPPoEsw(self):
        u'''PPPOE+PPPOE接入上网以及线路切换'''
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        ConnectState = getAssertText('ConnectState')
        #1、 WAN2口改为pppoe接入
        wan_config.click_line2edit()
        time.sleep(1)
        access_mode = wan_config.selelement_byName(wan_config.connectionType)
        Select(access_mode).select_by_value('PPPOE')
        time.sleep(1)
        wan_config.input_pppoeUser('222')  # 输入上层网关配置的PPPoE账号密码
        wan_config.input_pppoePass('222')
        wan_config.click_save()
        time.sleep(10)
        self.driver.quit()  # 修改接口后 可能会回到登录页面 所以关闭,再打开

        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        # 进入网络配置-外网配置
        wan_config.click_NetworkConfig()
        time.sleep(0.5)
        wan_config.click_WANconfig()
        time.sleep(1)
        # 断言
        n = 0
        while n < 30:
            wan_config.click_refresh()
            time.sleep(1)
            list_connectState1 = wan_config.getText_byXpath(
                wan_config.connectState1)
            list_connectState2 = wan_config.getText_byXpath(
                wan_config.connectState2)
            print(str(list_connectState1), str(list_connectState2))
            list_connectState = [
                str(list_connectState1),
                str(list_connectState2)
            ]
            # 动态接入 未获取到地址/wan口线未接入 都是未连接
            if all(t == ConnectState for t in list_connectState):
                print('WAN口均已连接', n)
                break
            else:
                time.sleep(2)
                n += 1
        else:
            raise Exception('WAN口未连接')
        # 获取两个wan口IP、mac,pppoe接口通过IP判断接口名,固定通过mac地址判断接口名
        line1_ip = str(wan_config.getText_byXpath(wan_config.line1IP))
        # print('line1_ip:', line1_ip)
        line2_ip = str(wan_config.getText_byXpath(wan_config.line2IP))
        # print('line2_ip:', line2_ip)

        time.sleep(10)  # 等待wan2路由生成

        # telnet获取接口名称及确认默认路由
        hostip = gettelnet('host')
        port = gettelnet('port')
        username = bytes(getweb('User'), encoding="utf8")
        password = bytes(getweb('Passwd'), encoding="utf8")
        # 获取接口名称
        tn = telnetlib.Telnet(host=hostip, port=port, timeout=10)
        tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
        tn.read_until(b'login:'******'Password:'******'ip route' + b'\n')
        # 输出结果,判断
        time.sleep(1)
        result = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
        print('-------------------输出结果------------------------')
        # 命令执行结果
        print('result:', result)
        # 获取WAN1对应接口名称
        result1 = result[2:-7]
        print('result1', result1)
        result2 = result1.split(r'\r\n')
        print('result2', result2)

        for x in range(len(result2)):
            if line1_ip in result2[x]:
                result2_num1 = (result2[x])
                print(result2_num1)
                line1_Interface_name = result2_num1.split()[2]
                print(line1_Interface_name)
            if line2_ip in result2[x]:
                result2_num1 = (result2[x])
                print(result2_num1)
                line2_Interface_name = result2_num1.split()[2]
                print(line2_Interface_name)
        if line1_Interface_name == None:
            raise Exception('获取wan1口对应接口名称失败')
        if line2_Interface_name == None:
            raise Exception('获取wan2口对应接口名称失败')

        # 确认默认路由情况
        wan1route = 'nexthop dev ' + line1_Interface_name + ' weight '
        wan2route = 'nexthop dev ' + line2_Interface_name + ' weight '
        print('wan1route:', wan1route, 'wan2route:', wan2route)

        for i in range(len(result2)):
            if wan1route in result2[i]:
                wan1route_status = not None
                print('wan1路由在')
            if wan2route in result2[i]:
                wan2route_status = not None
                print('wan2路由在')
        if wan1route_status == None:
            raise Exception('wan1默认路由不存在')
        if wan2route_status == None:
            raise Exception('wan2默认路由不存在')
        tn.close()  # tn.write('exit\n')
        self.driver.quit()

        # 2、设置线路检测地址,验证线路切换
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        # 进入网络配置-外网配置
        wan_config.click_NetworkConfig()
        time.sleep(0.5)
        wan_config.click_WANconfig()
        time.sleep(1)
        # 配置线路检测 检测3s 检测 3次,地址为223.5.5.5
        wan_config.click_GlobalConfig()
        time.sleep(1)
        wan_config.input_KeepLive1('3')
        wan_config.input_RetryTimes1('3')
        sel1 = wan_config.selelement_byName(wan_config.PriAddrType1)
        Select(sel1).select_by_value('others')
        time.sleep(0.5)
        wan_config.input_DestIP1('223.5.5.5')

        wan_config.input_KeepLive2('3')
        wan_config.input_RetryTimes2('3')
        sel2 = wan_config.selelement_byName(wan_config.PriAddrType2)
        Select(sel2).select_by_value('others')
        time.sleep(0.5)
        wan_config.input_DestIP2('1.2.3.4')  # WAN2配一个ping不通的地址,测试线路切换
        wan_config.click_save()
        time.sleep(2)
        # 等待弹窗提示成功
        i = 0
        while i < 80:
            try:
                self.driver.implicitly_wait(1)
                wan_config.find_tipsshowin()
            except NoSuchElementException:
                time.sleep(1)
                i = i + 1
                print(i)
            else:
                tips = str(
                    wan_config.getAttribute_byClass(wan_config.tipsshowin,
                                                    'tip-sign'))
                print(tips, i)
                if tips != 'success':
                    CapPic(self.driver)
                    logger.info(u'线路检测保存 异常')
                    raise Exception(u'线路检测保存 异常')
                break
        else:
            raise Exception(u'线路检测保存 未弹出提示框')
        # 切换标签页判断配置正确
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_GlobalConfig()
        time.sleep(1)
        KeepLive2 = str(
            wan_config.getAttribute_byName(wan_config.KeepLive2v, 'value'))
        RetryTimes2 = str(
            wan_config.getAttribute_byName(wan_config.RetryTimes2v, 'value'))
        DestIP2 = str(
            wan_config.getAttribute_byName(wan_config.DestIP2v, 'value'))
        self.assertEqual(KeepLive2, '3', msg='wan2检测间隔与设置不一致')
        self.assertEqual(RetryTimes2, '3', msg='wan2检测次数与设置不一致')
        self.assertEqual(DestIP2, '1.2.3.4', msg='wan2检测地址与设置不一致')

        # telnet确认默认路由(wan2检测地址不通,默认路由应切换成wan1)
        # wan2检测不通,这里只判断wan1的
        # 单线路默认路由变为ru:default dev ppp0 equalize  不再有weight值
        # (高通没有equalize):default via 192.168.12.1 dev eth0.3
        wan1route1 = 'default dev ' + line1_Interface_name
        print('wan1route:', wan1route1)
        roure1 = bytes(('ip route | grep "%s"') % line1_Interface_name,
                       encoding="utf8")
        time.sleep(10)  # 等待检测,路由切换
        x = 0
        while x < 60:
            tn = telnetlib.Telnet(host=hostip, port=port, timeout=10)
            tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
            tn.read_until(b'login:'******'Password:'******'\n')
            # 输出结果,判断
            time.sleep(1)
            result3 = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            # print('result3:', result3)
            # 获取WAN1对应接口名称
            result4 = result3[1:]
            # print('result4', result4)
            result5 = result4.replace('\r\n', ' ')
            # print('result5', result2)
            tn.close()
            if 'default' in result5 and wan1route1 in result5:
                print('wan1路由在')
                break
            else:
                print(x)
                time.sleep(2)
                x += 1
        else:
            logger.info(u'wan1route1: %s' % wan1route1)
            logger.info(u'result5 %s' % result5)
            raise Exception('wan1默认路由显示有误')

        # 3、将wan2检测目标改正确,线路、路由切换回来
        wan_config.input_DestIP2('223.5.5.5')  # WAN2检测地址改可ping通,测试线路切换
        wan_config.click_save()
        time.sleep(2)
        # 等待弹窗提示成功
        i = 0
        while i < 80:
            try:
                self.driver.implicitly_wait(1)
                wan_config.find_tipsshowin()
            except NoSuchElementException:
                time.sleep(1)
                i = i + 1
                print(i)
            else:
                tips = str(
                    wan_config.getAttribute_byClass(wan_config.tipsshowin,
                                                    'tip-sign'))
                print(tips, i)
                if tips != 'success':
                    CapPic(self.driver)
                    logger.info(u'线路检测保存 异常')
                    raise Exception(u'线路检测保存 异常')
                break
        else:
            raise Exception(u'线路检测保存 未弹出提示框')
        # 切换标签页判断配置正确
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_GlobalConfig()
        time.sleep(1)
        DestIP2 = str(
            wan_config.getAttribute_byName(wan_config.DestIP2v, 'value'))
        self.assertEqual(DestIP2, '223.5.5.5', msg='wan2检测地址与设置不一致')

        # 确认默认路由情况(wan2检测地址通,默认路由应切换成wan2)
        wan1route2 = 'nexthop dev ' + line1_Interface_name + ' weight '
        wan2route2 = 'nexthop dev ' + line2_Interface_name + ' weight '
        print('wan1route:', wan1route, 'wan2route:', wan2route)
        time.sleep(10)  # 等待检测,路由切换
        x = 0
        while x < 60:
            tn = telnetlib.Telnet(host=hostip, port=port, timeout=10)
            tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
            tn.read_until(b'login:'******'Password:'******'ip route' + b'\n')
            # 输出结果,判断
            time.sleep(1)
            result6 = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            # print('result6:', result6)
            # 获取WAN1对应接口名称
            result7 = result6[1:]
            # print('result7', result7)
            result8 = result7.replace('\r\n', ' ')
            # print('result8', result8)
            tn.close()
            if (wan1route2 in result8) and (wan2route2 in result8):
                print('wan1/wan2路由在')
                break
            else:
                print(x)
                time.sleep(2)
                x += 1
        else:
            logger.info(u'wan1route_2: %s' % wan1route2)
            logger.info(u'wan2route_2: %s' % wan2route2)
            logger.info(u'result8 %s' % result8)
            raise Exception('wan1/wan2默认路由显示有误')

        #取消线路检测
        wan_config.click_GlobalConfig()
        time.sleep(1)
        wan_config.input_KeepLive1('0')
        wan_config.input_KeepLive2('0')
        wan_config.click_save()
        # 等待弹窗提示成功
        i = 0
        while i < 80:
            try:
                self.driver.implicitly_wait(1)
                wan_config.find_tipsshowin()
            except NoSuchElementException:
                time.sleep(1)
                i = i + 1
                print(i)
            else:
                tips = str(
                    wan_config.getAttribute_byClass(wan_config.tipsshowin,
                                                    'tip-sign'))
                print(tips, i)
                if tips != 'success':
                    CapPic(self.driver)
                    logger.info(u'线路检测保存 异常')
                    raise Exception(u'线路检测保存 异常')
                break
        else:
            raise Exception(u'线路检测保存 未弹出提示框')
        # 切换标签页判断配置正确
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_GlobalConfig()
        time.sleep(1)
        KeepLive1 = str(
            wan_config.getAttribute_byName(wan_config.KeepLive1v, 'value'))
        KeepLive2 = str(
            wan_config.getAttribute_byName(wan_config.KeepLive2v, 'value'))
        self.assertEqual(KeepLive1, '0', msg='wan1检测间隔不为0')
        self.assertEqual(KeepLive2, '0', msg='wan2检测间隔不为0')
        # WAN1改回动态接入,得到正确的IP地址及网关地址
        wan_config.click_WANconfig()
        time.sleep(1)
        # WAN1
        wan_config.click_line1edit()
        time.sleep(1)
        access_mode = wan_config.selelement_byName(wan_config.connectionType)
        Select(access_mode).select_by_value('DHCP')
        wan_config.click_save()
        time.sleep(10)
        self.driver.quit()
        logger.info('test_004_PPPoEsw passed')
示例#7
0
    def test_002_backupLineSW(self):
        u'''双固定IP接入时的线路切换:主、备份线路'''
        wan_config = NetworkConfig_wanpage(self.driver, self.url)
        #1、获取wan1、wan2 网关及mac
        line1_mac = str(wan_config.getText_byXpath(wan_config.line1Mac))
        # print('WAN1_dns=',line1_mac)
        line2_mac = str(wan_config.getText_byXpath(wan_config.line2Mac))
        # print('WAN1_dns=',line2_mac)
        # 处理wan口的mac地址
        # 字母变大写
        line1_mac1 = line1_mac.upper()
        line2_mac1 = line2_mac.upper()
        # 加冒号
        line1_mac2 = line1_mac1[0:2] + ':' + line1_mac1[
            2:4] + ':' + line1_mac1[4:6] + ':' + line1_mac1[
                6:8] + ':' + line1_mac1[8:10] + ':' + line1_mac1[10:]
        line2_mac2 = line2_mac1[0:2] + ':' + line2_mac1[
            2:4] + ':' + line2_mac1[4:6] + ':' + line2_mac1[
                6:8] + ':' + line2_mac1[8:10] + ':' + line2_mac1[10:]
        print(line1_mac2, line2_mac2)

        #WAN1改为备份线路
        wan_config.click_line1edit()
        time.sleep(1)
        line_type = wan_config.selelement_byXpath(wan_config.line_type)
        Select(line_type).select_by_value('0')  #1为主 0为备份
        wan_config.click_save()
        time.sleep(10)
        n = 0
        while n < 20:
            ping = pingTestIP()
            if ping != 'Y':
                time.sleep(1)
                n += 1
            else:
                break
        self.driver.quit()

        # telnet获取接口名称及确认默认路由(wan1备份应该只剩下wan2默认路由)
        hostip = gettelnet('host')
        port = gettelnet('port')
        username = bytes(getweb('User'), encoding="utf8")
        password = bytes(getweb('Passwd'), encoding="utf8")
        # 获取接口名称
        tn = telnetlib.Telnet(host=hostip, port=port, timeout=10)
        tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
        tn.read_until(b'login:'******'Password:'******'#')
        tn.write(b'ifconfig | grep eth' + b'\n')
        # 输出结果,判断
        time.sleep(1)
        result = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
        print('-------------------输出结果------------------------')
        # 命令执行结果
        print('result:', result)
        # 获取WAN口对应接口名称
        result1 = result[3:-9]
        # print(result1)
        result2 = result1.split(r'\r\n')
        print('result2:', result2)

        for i in range(len(result2)):
            if line1_mac2 in result2[i]:
                result2_num = (result2[i])
                print(result2[i])
                line1_Interface_name = result2_num.split()[0]
                print(line1_Interface_name)
            if line2_mac2 in result2[i]:
                result2_num = (result2[i])
                print(result2[i])
                line2_Interface_name = result2_num.split()[0]
                print(line2_Interface_name)
        if line1_Interface_name == None:
            raise Exception('获取wan1口对应接口名称失败')
        if line2_Interface_name == None:
            raise Exception('获取wan2口对应接口名称失败')
        # 确认默认路由情况
        roure1 = bytes(('ip route | grep "%s"') % line2_Interface_name,
                       encoding="utf8")
        tn.write(roure1 + b'\n')
        # 输出结果,判断
        time.sleep(1)
        result = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
        print('-------------------输出结果------------------------')
        # 命令执行结果
        print('result:', result)
        # 获取WAN1对应接口名称
        result1 = result[2:-7]
        print('result1', result1)
        result2 = result1.split(r'\r\n')
        print('result2', result2)
        #wan1已备份,只剩wan2路由,这里只判断wan2的
        wan2route = 'dev ' + line2_Interface_name
        print('wan2route:', wan2route)

        for i in range(len(result2)):
            if 'default' in result2[i] and wan2route in result2[i]:
                wan2route_status = not None
                print('wan2路由在')
        if wan2route_status == None:
            raise Exception('wan2默认路由显示有误')
        #单线路默认路由变为:default via 192.168.11.1 dev eth2.3 equalize 不再有weight值
        # (高通没有equalize):default via 192.168.12.1 dev eth0.3
        #多线mtk
        # default equalize
        #    nexthop via 192.168.32.1  dev eth2.2 weight 1
        #    nexthop via 192.168.200.1  dev eth2.3 weight 1
        # 多线高通
        # default
        #    nexthop via 192.168.11.1  dev eth0.2 weight 1
        #    nexthop via 192.168.11.1  dev eth0.3 weight 1

        tn.close()  # tn.write('exit\n')

        #2、设置线路检测地址,验证线路切换
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        wan_config = NetworkConfig_wanpage(self.driver, self.url)

        # 进入网络配置-外网配置
        wan_config.click_NetworkConfig()
        time.sleep(0.5)
        wan_config.click_WANconfig()
        time.sleep(1)
        #配置线路检测 检测3s 检测 3次,地址为223.5.5.5
        wan_config.click_GlobalConfig()
        time.sleep(1)
        wan_config.input_KeepLive1('3')
        wan_config.input_RetryTimes1('3')
        sel1 = wan_config.selelement_byName(wan_config.PriAddrType1)
        Select(sel1).select_by_value('others')
        time.sleep(0.5)
        wan_config.input_DestIP1('223.5.5.5')

        wan_config.input_KeepLive2('3')
        wan_config.input_RetryTimes2('3')
        sel2 = wan_config.selelement_byName(wan_config.PriAddrType2)
        Select(sel2).select_by_value('others')
        time.sleep(0.5)
        wan_config.input_DestIP2('1.2.3.4')  #WAN2配一个ping不通的地址,测试线路切换
        wan_config.click_save()
        time.sleep(2)
        # 等待弹窗提示成功
        i = 0
        while i < 80:
            try:
                self.driver.implicitly_wait(1)
                wan_config.find_tipsshowin()
            except NoSuchElementException:
                time.sleep(1)
                i = i + 1
                print(i)
            else:
                tips = str(
                    wan_config.getAttribute_byClass(wan_config.tipsshowin,
                                                    'tip-sign'))
                print(tips, i)
                if tips != 'success':
                    CapPic(self.driver)
                    logger.info(u'线路检测保存 异常')
                    raise Exception(u'线路检测保存 异常')
                break
        else:
            raise Exception(u'线路检测保存 未弹出提示框')

        #切换标签页判断配置正确
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_GlobalConfig()
        time.sleep(1)
        KeepLive2 = str(
            wan_config.getAttribute_byName(wan_config.KeepLive2v, 'value'))
        RetryTimes2 = str(
            wan_config.getAttribute_byName(wan_config.RetryTimes2v, 'value'))
        DestIP2 = str(
            wan_config.getAttribute_byName(wan_config.DestIP2v, 'value'))
        self.assertEqual(KeepLive2, '3', msg='wan2检测间隔与设置不一致')
        self.assertEqual(RetryTimes2, '3', msg='wan2检测次数与设置不一致')
        self.assertEqual(DestIP2, '1.2.3.4', msg='wan2检测地址与设置不一致')

        # 确认默认路由情况
        # 单线路默认路由变为:default via 192.168.11.1 dev eth2.2 equalize 不再有weight值
        wan1route1 = 'dev ' + line1_Interface_name
        print('wan1route:', wan1route1)
        roure1 = bytes(('ip route | grep "%s"') % line1_Interface_name,
                       encoding="utf8")

        time.sleep(10)  # 等待检测,路由切换
        x = 0
        while x < 60:
            tn = telnetlib.Telnet(host=hostip, port=port, timeout=10)
            tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
            tn.read_until(b'login:'******'Password:'******'\n')
            # 输出结果,判断
            time.sleep(1)
            result = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            # print('result:', result)
            result4 = result[1:]
            # print('result4', result4)
            result5 = result4.replace('\r\n', ' ')
            print('result5', result5)
            tn.close()
            # wan2、wan3检测不通,这里判断仅wan1在
            if 'default' in result5 and wan1route1 in result5:
                print('wan1路由在')
                break
            else:
                print(x)
                time.sleep(2)
                x += 1
        else:
            logger.info(u'wan1route1: %s' % wan1route1)
            logger.info(u'result5: %s' % result5)
            raise Exception('wan1默认路由显示有误')

        #3、将wan2检测目标改正确,线路、路由切换回来
        wan_config.input_DestIP2('223.5.5.5')  # WAN2检测地址改可ping通,测试线路切换
        wan_config.click_save()
        time.sleep(2)
        # 等待弹窗提示成功
        i = 0
        while i < 80:
            try:
                self.driver.implicitly_wait(1)
                wan_config.find_tipsshowin()
            except NoSuchElementException:
                time.sleep(1)
                i = i + 1
                print(i)
            else:
                tips = str(
                    wan_config.getAttribute_byClass(wan_config.tipsshowin,
                                                    'tip-sign'))
                print(tips, i)
                if tips != 'success':
                    CapPic(self.driver)
                    logger.info(u'线路检测保存 异常')
                    raise Exception(u'线路检测保存 异常')
                break
        else:
            raise Exception(u'线路检测保存 未弹出提示框')
        # 切换标签页判断配置正确
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_GlobalConfig()
        time.sleep(1)
        DestIP2 = str(
            wan_config.getAttribute_byName(wan_config.DestIP2v, 'value'))
        self.assertEqual(DestIP2, '223.5.5.5', msg='wan2检测地址与设置不一致')

        time.sleep(20)  # 等待检测,路由切换
        # 确认默认路由情况(wan2检测地址通,默认路由应切换成wan2)
        # 单线路默认路由变为:default via 192.168.11.1 dev eth2.2 equalize 不再有weight值
        wan2route1 = 'dev ' + line2_Interface_name
        print('wan2route1:', wan2route1)
        roure1 = bytes(('ip route | grep "%s"') % wan2route1, encoding="utf8")
        x = 0
        while x < 60:
            tn = telnetlib.Telnet(host=hostip, port=port, timeout=10)
            tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
            tn.read_until(b'login:'******'Password:'******'\n')
            # 输出结果,判断
            time.sleep(1)
            result = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            # print('result:', result)
            result4 = result[1:]
            # print('result4', result4)
            result5 = result4.replace('\r\n', ' ')
            print('result5', result5)
            # wan2、wan3检测不通,这里只判断wan1的
            tn.close()
            if 'default' in result5 and wan2route1 in result5:
                print('wan2路由在')
                break
            else:
                print(x)
                time.sleep(2)
                x += 1
        else:
            logger.info(u'wan2route1: %s' % wan2route1)
            logger.info(u'result5: %s' % result5)
            raise Exception('wan2默认路由显示有误')

        #4、wan1口改回主线路
        wan_config.click_WANconfig()
        time.sleep(1)
        wan_config.click_line1edit()
        time.sleep(1)
        line_type = wan_config.selelement_byXpath(wan_config.line_type)
        Select(line_type).select_by_value('1')  # 1为主 0为备份
        wan_config.click_save()
        time.sleep(10)  # 修改接口后 可能会回到登录页面 所以关闭,再打开
        self.driver.quit()

        # telnet获取接口名称及确认默认路由
        wan1route_2 = 'dev ' + line1_Interface_name + ' weight '
        wan2route_2 = 'dev ' + line2_Interface_name + ' weight '
        print('wan1route_2:', wan1route_2, 'wan2route_2:', wan2route_2)
        time.sleep(10)
        # 获取接口名称
        x = 0
        while x < 60:
            tn = telnetlib.Telnet(host=hostip, port=port, timeout=10)
            tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
            tn.read_until(b'login:'******'Password:'******'#')
            # 确认默认路由情况
            tn.write(b'ip route' + b'\n')
            # 输出结果,判断
            time.sleep(1)
            result9 = str(tn.read_very_eager())  # 执行多条命令时只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            # print('result9:', result9)
            # 获取WAN1对应接口名称
            result10 = result9[1:]
            # print('result10', result10)
            result11 = result10.replace('\r\n', ' ')
            print('result11', result11)
            tn.close()
            if (wan1route_2 in result11) and (wan2route_2 in result11):
                print('wan1/wan2路由在')
                break
            else:
                print(x)
                time.sleep(2)
                x += 1
        else:
            logger.info(u'wan1route_2: %s' % wan1route_2)
            logger.info(u'wan2route_2: %s' % wan2route_2)
            logger.info(u'result11 %s' % result11)
            raise Exception('wan1/wan2默认路由显示有误')

        logger.info('test_002_backupLineSW passed')