Exemple #1
0
    def test_003_test3(self):
        u'''已删除账号验证 只读权限验证'''
        pageTipWarnA = getAssertText('pageTipWarnA')
        #使用test账号不能登陆管理DUT
        login.test_unableLoginWeb(self, username='******', password='******')
        self.driver.implicitly_wait(10)
        self.driver.quit()

        #使用test1账号可以登陆管理DUT
        login.test_enableLoginWeb(self, username='******', password='******')
        self.driver.implicitly_wait(10)
        # 只读权限test1 尝试删除test1/test1账号,应该不成功
        administrator = ManagementPolicyPage(self.driver, self.url)
        administrator.click_sysConfig()
        time.sleep(0.5)
        administrator.click_ManagementPolicy()
        time.sleep(1)
        #尝试删除test1/test1账号,应该不成功
        administrator.click_listDelete1()
        time.sleep(1)
        administrator.click_ok()
        time.sleep(1)
        # 断言删除时候提示信息(logout_span)元素不为空:代表无法删除
        pageTip_warn = administrator.getText_byClass(
            administrator.pageTip_warn)
        if pageTip_warn != pageTipWarnA:
            CapPic(self.driver)
            logger.info(u'只读权限删除提示有误')
            raise Exception('只读权限删除提示有误')
        else:
            print('已删除账号验证、只读权限验证 通过')
        self.driver.quit()
    def tearDown(self):

        nodata = getAssertText('nodata')
        #删除ipsec
        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        ipsec = IPsecPage(self.driver, self.url)
        ipsec.click_VPNConfig()
        time.sleep(0.5)
        ipsec.click_IPSec()
        time.sleep(1)
        ipsec.click_selall()
        time.sleep(0.2)
        ipsec.click_delall()
        time.sleep(1)
        ipsec.click_ok()
        time.sleep(2)
        list_nodata = ipsec.getText_byXpath(ipsec.list_nodata)
        if list_nodata == nodata:
            logger.info(u'R1 ipsec 已删除')
        else:
            CapPic(self.driver)
            logger.info(u'R1 ipsec删除失败')
            raise Exception(u'R1 ipsec删除失败')
        self.driver.quit()
        login.test_enableLoginWeb(self, url=vpnRouteUrl)
        ipsec = IPsecPage(self.driver, self.url)
        ipsec.click_VPNConfig()
        time.sleep(0.5)
        ipsec.click_IPSec()
        time.sleep(1)
        ipsec.click_selall()
        time.sleep(0.2)
        ipsec.click_delall()
        time.sleep(1)
        ipsec.click_ok()
        time.sleep(2)
        try:  #VPN 路由器是中文简体,在测试其他语言版本时,删除的nodata会不一致
            ipsec.find_list_nodataX()
        except NoSuchElementException:
            CapPic(self.driver)
            logger.info(u'R2 ipsec删除失败')
            raise Exception(u'R2 ipsec删除失败')
        else:
            logger.info(u'R2 ipsec 已删除')

        # list_nodata = ipsec.getText_byXpath(ipsec.list_nodata)
        # if list_nodata == nodata:
        #     logger.info(u'R2 ipsec 已删除')
        # else:
        #     CapPic(self.driver)
        #     logger.info(u'R2 ipsec删除失败')
        #     raise Exception(u'R2 ipsec删除失败')

        logger.info('tearDown over')
        logger.info('%s' % ('=' * 50))
    def test_001_AccessMode(self):
        u'''https模式登录'''
        host = gettelnet('host')
        RouteUrls = 'https://' + host + '/'

        # 修改网管模式,端口切换到443,https模式下可登录设备
        accessStrategy = ManagementPolicyPage(self.driver, self.url)
        accessStrategy.click_httpswebEn()
        accessStrategy.click_save()
        # 加个判断 某些型号等待时间长(6550G)
        time.sleep(1)
        x = 0
        while x < 15:
            now_url = str(self.driver.current_url)
            print(now_url, x)
            if '/noAuth/login.html' not in now_url:  # 如果不同
                time.sleep(2)
            else:
                break
            x += 1
        self.driver.quit()

        #https模式下验证登录设备
        login.test_enableLoginWeb(self, url=RouteUrls)  #https登录
        accessStrategy = ManagementPolicyPage(self.driver, self.url)
        # 改回http 方式登录
        accessStrategy.click_sysConfig()
        time.sleep(0.5)
        accessStrategy.click_ManagementPolicy()
        time.sleep(1)
        accessStrategy.click_AccessPolicy()
        time.sleep(1)
        accessStrategy.click_httpwebEn()
        accessStrategy.click_save()
        time.sleep(1)
        i = 0
        while i < 30:
            url = self.driver.current_url
            if '/login.html' in url:
                break
            else:
                time.sleep(2)
            i += 1

        self.driver.quit()
        logger.info('test_001_AccessMode passed')
Exemple #4
0
 def test_002_test2(self):
     u'''新增账号登录 修改权限'''
     RouteUrl = getweb('RouteUrl')
     self.url = RouteUrl
     #能使用test该账号登陆管理DUT
     login.test_enableLoginWeb(self, username='******', password='******')
     # self.url = RouteUrl
     self.driver.implicitly_wait(10)
     administrator = ManagementPolicyPage(self.driver, self.url)
     administrator.click_sysConfig()
     time.sleep(0.5)
     administrator.click_ManagementPolicy()
     time.sleep(1)
     #修改test/test为test1/test1,(测试:账号权限一起改 提交时候权限未改成功,这里分两步完成)
     administrator.click_listEdit1()
     time.sleep(1)
     administrator.input_username('test1')
     administrator.input_passwd1('test1')
     administrator.input_passwd2('test1')
     administrator.click_save()
     time.sleep(1)
     self.driver.quit()
     #重新登录--只为修改test1的权限(可以使用test1登录也验证了上一步修改成功)
     login.test_enableLoginWeb(self, username='******', password='******')
     self.driver.implicitly_wait(10)
     administrator = ManagementPolicyPage(self.driver, self.url)
     administrator.click_sysConfig()
     time.sleep(0.5)
     administrator.click_ManagementPolicy()
     time.sleep(1)
     #修改test1/test1,为只读权限。
     administrator.click_listEdit1()
     time.sleep(1)
     selrole = administrator.selelement_byName(administrator.role)
     Select(selrole).select_by_value('viewer')  #改为只读权限
     time.sleep(1)
     administrator.click_input_group()  #修改后点击下其他元素,避免没有保存成功
     time.sleep(1)
     administrator.click_save()
     time.sleep(1)
     self.driver.quit()
Exemple #5
0
    def test_004_test4(self):
        u'''删除新增账号 admin登录验证'''
        #删除test1/test1,会退出当前登陆(test1已经修改了权限 用admin删除)
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        administrator = ManagementPolicyPage(self.driver, self.url)
        # 进入系统配置-网管策略-系统管理员
        administrator.click_sysConfig()
        time.sleep(0.5)
        administrator.click_ManagementPolicy()
        time.sleep(1)
        #删除test1/test1
        administrator.click_listDelete1()
        time.sleep(1)
        administrator.click_ok()
        time.sleep(1)
        # 断言列表框里第二行没有值、元素为空:代表删除成功
        list2_nodata = administrator.getText_byXpath(
            administrator.list2_nodata)
        if list2_nodata != ' ':
            CapPic(self.driver)
            logger.info(u'删除test1/test1 有误')
            raise Exception('删除test1/test1 有误')
        else:
            print('删除test1/test1 通过')
        self.driver.quit()

        #删除后使用test1不可以登录
        login.test_unableLoginWeb(self, username='******', password='******')
        time.sleep(1)
        self.driver.quit()
        #使用admin/admin可以登陆
        login.test_enableLoginWeb(self, username='******', password='******')
        time.sleep(1)
        self.driver.quit()
        print('管理员账号测试 验证通过')
    def test_001_ipsec(self):
        u'''ipsec VPN'''
        vpnRouteLan = getweb('vpnRouteLan')
        host = gettelnet('host')
        StateVPN1 = getAssertText('StateVPN1')
        WillReboottips = getAssertText('WillReboottips')

        #先判断是否可以上网
        p = pingTestIP()
        if p == 'N':
            os.system('%s' % (batpath + 'changeDhcpIp.bat'))
            time.sleep(5)
            n = 0
            while n < 30:
                pcaddr = socket.gethostbyname(
                    socket.getfqdn(socket.gethostname()))
                print(pcaddr, n)
                if '192.168.' not in str(pcaddr):
                    time.sleep(2)
                    n += 1
                else:
                    print('IP地址已自动获取成功', n)
                    break
            else:
                raise Exception('未获取到地址')
            # 删除绑定绑定 清空组
            organization_group.group_delete(self)

        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        ipsec = IPsecPage(self.driver, self.url)
        ipsec.click_VPNConfig()
        time.sleep(0.5)
        ipsec.click_IPSec()
        time.sleep(1)
        # 操作删除 以访已有规则
        ipsec.click_selall()
        time.sleep(0.2)
        ipsec.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            ipsec.find_ok()
        except NoSuchElementException:
            try:
                ipsec.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('ipsec VPN列表为空')

        ipsec.click_add()
        time.sleep(1)
        ipsec.input_ids('test')
        ipsec.input_peer(vpnRouteWan)
        ipsec.input_remoteAddr(vpnRouteLan)
        # ipsec.input_remoteMask('255.255.255.0')
        ipsec.input_preshareKey('12345678')
        ipsec.click_save()
        time.sleep(2)
        try:  #无线设备增加ac功能后 配置第一条ipsec时会提示重启
            ipsec.find_ok()
        except NoSuchElementException:
            pass
        else:
            time.sleep(2)
            tips = str(ipsec.getText_byClass(ipsec.u_tim_str))
            self.assertEqual(tips, WillReboottips, msg='点击提示重启 操作失败')
            # 设备重启时间不一致,做个判断
            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('设备重启未正常启动')
            self.driver.quit()
            login.loginWeb(self)

        # 从外网配置页面获取WAN1口地址
        wanpage = NetworkConfig_wanpage(self.driver, self.url)
        wanpage.click_NetworkConfig()
        time.sleep(0.5)
        wanpage.click_WANconfig()
        time.sleep(1)

        # 判断联网状态
        i = 0
        while i < 21:
            wanpage.click_refresh()
            time.sleep(1)
            list_conState = wanpage.getText_byXpath(wanpage.connectState1)
            print(str(list_conState), i)
            if str(list_conState) != ConnectState:
                time.sleep(3)
                i += 1
            else:
                break
        else:
            CapPic(self.driver)
            logger.info(u"WAN口未连接")
            raise Exception('WAN1 未连接')
        i = 0
        while i < 21:
            # 判断联网 ,不能上网则报错
            p = pingTestIP('www.baidu.com')
            print(p, i)
            if p == 'N':
                time.sleep(3)
                i += 1
            else:
                break
        else:
            logger.info(u"connect failed")
            raise Exception('connect failed.')

        # WAN1 ip变量赋值,页面读取
        WAN1_ip = str(wanpage.getText_byXpath(wanpage.line1IP))
        # print('WAN1_ip=',WAN1_ip)
        time.sleep(1)
        self.driver.quit()

        # 另外一台路由器 配置ipsec
        i = 0  #以访刚重启wan口还不通
        while i < 60:
            pingTestIP(vpnRouteWan)
            if p == 'N':
                time.sleep(1)
                i += 1
            else:
                break
        else:
            raise Exception(u'无法ping通vpnRoute')
        # time.sleep(5)
        login.test_enableLoginWeb(self, url=vpnRouteUrl)
        ipsec = IPsecPage(self.driver, self.url)
        ipsec.click_VPNConfig()
        time.sleep(0.5)
        ipsec.click_IPSec()
        time.sleep(1)
        # 操作删除 以访已有规则
        ipsec.click_selall()
        time.sleep(0.2)
        ipsec.click_delall()
        time.sleep(1)
        try:
            self.driver.implicitly_wait(2)
            ipsec.find_ok()
        except NoSuchElementException:
            try:
                ipsec.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('ipsec VPN列表为空')

        ipsec.click_add()
        time.sleep(1)
        ipsec.input_ids('test')
        ipsec.input_peer(WAN1_ip)
        ipsec.input_remoteAddr(host)
        # ipsec.input_remoteMask('255.255.255.0')
        ipsec.input_preshareKey('12345678')
        ipsec.click_save()
        time.sleep(2)

        i = 0
        while i < 100:
            ipsec.click_IPSec()
            time.sleep(1)
            list_status = ipsec.getText_byXpath(ipsec.list_status)
            print(list_status)
            if list_status == StateVPN1:
                logger.info(u'ipsec 已建立')
                break
            else:
                time.sleep(3)
                i += 1
        else:
            logger.info(u'ipsec 未建立成功')
            CapPic(self.driver)
            raise Exception(u'ipsec未建立成功')

        self.driver.quit()
        logger.info('test_001_ipsec passed')
Exemple #7
0
    def test_001_openRemote(self):
        u'''开启远程管理'''
        # 开启远程管理
        remoteManage = ManagementPolicyPage(self.driver, self.url)
        remoteManage.click_httpEn()
        time.sleep(0.5)
        remoteManage.click_save()
        time.sleep(1)

        #检查admin的映射是否开启
        staticMapping = staticMappingPage(self.driver, self.url)
        staticMapping.click_NetworkConfig()
        time.sleep(0.5)
        staticMapping.click_portMapping()
        time.sleep(1)
        list_Ens = staticMapping.getAttribute_byXpath(staticMapping.list1_Ens,
                                                      'checked')
        if list_Ens != 'true':
            CapPic(self.driver)
            logger.info(u'开启远程管理 静态映射未打开')
            raise Exception(u'远程管理 静态映射未打开')

        # 从外网配置页面获取WAN1口地址
        wanpage = NetworkConfig_wanpage(self.driver, self.url)
        wanpage.click_WANconfig()
        time.sleep(1)
        # 判断联网状态
        i = 0
        while i < 21:
            wanpage.click_refresh()
            time.sleep(1)
            list_conState = wanpage.getText_byXpath(wanpage.connectState1)
            print(str(list_conState), i)
            if str(list_conState) != ConnectState:
                time.sleep(3)
                i += 1
            else:
                break
        else:
            CapPic(self.driver)
            logger.info(u"WAN口未连接")
            raise Exception('WAN1 未连接')
        WAN1_ip = str(wanpage.getText_byXpath(wanpage.line1IP))
        time.sleep(1)
        self.driver.quit()

        if CPUmodel == 'Qualcomm':
            # 部分型号,如高通1200Wv2,因为芯片问题必须关闭wan口mac学习功能,原mac未清除之前无法从wan口访问路由器
            # 这里需要设置计划任务2分钟后清空原pc的arp缓存
            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"uptime" + b"\n")
            # 输出结果,判断
            time.sleep(1)
            result = str(tn.read_very_eager())  # 只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            print('result:', result)
            result1 = str(result.split(r'\r\n')[1]).split(r':')
            print(result1[1])
            tn.close()  # tn.write('exit\n')
            if int(result1[1]) + 2 < 60:
                hour = result1[0]
                min = int(result1[1]) + 2
            else:
                if int(result1[0]) + 1 < 24:
                    hour = int(result1[0]) + 1
                    min = '0' + str((int(result1[1]) + 2) - 60)
                else:
                    hour = '0' + str(int(result1[0]) + 1 - 24)
                    min = '0' + str((int(result1[1]) + 2) - 60)
            print(hour)
            print(min)
            pcaddr = str(
                socket.gethostbyname(socket.getfqdn(socket.gethostname())))
            cmd = "echo '%s %s * * * arp -d %s' > cmd " % (min, hour, pcaddr)
            print(cmd)
            cmd = bytes(cmd, encoding='utf8')
            tn = telnetlib.Telnet(host=hostip, port=port, timeout=10)
            tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
            # 输入登录用户名
            tn.read_until(b'login:'******'Password:'******'#')
            tn.write(cmd + b"\n")
            tn.read_until(b'#')
            tn.write(b"cat cmd >> /var/spool/cron/crontabs/admin" + b"\n")
            tn.read_until(b'#')
            tn.write(b"killall crond" + b"\n")
            tn.read_until(b'#')
            tn.write(b"crond &" + b"\n")
            tn.read_until(b'#')
            tn.write(b"cat /var/spool/cron/crontabs/admin" + b"\n")
            # 输出结果,判断
            time.sleep(1)
            result = str(tn.read_very_eager())  # 只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            print('result:', result)
            if 'adp -d' in result:
                print('计划任务已写入')

        #更改pc 交换机接口与wan口/上联口通
        swconfig.test_LanToWan(self)
        if CPUmodel == 'Qualcomm':
            time.sleep(110)  # 等待计划任务执行
        #重新获取地址 应获取到上层网关下发的地址
        pcaddr = str(socket.gethostbyname(socket.getfqdn(
            socket.gethostname())))
        # 调用bat脚本 IP地址释放
        os.system('%s' % (batpath + 'ipconfig_release.bat'))
        time.sleep(2)
        pcaddr1 = str(
            socket.gethostbyname(socket.getfqdn(socket.gethostname())))
        print(pcaddr1)
        if pcaddr1 != str(pcaddr):
            print('IP地址已释放')
        else:
            time.sleep(3)
        time.sleep(2)
        # 将IP改回自动获取(设置dns为自动获取)
        # 调用bat脚本
        os.system('%s' % (batpath + 'ipconfig_renew.bat'))
        time.sleep(5)
        n = 0
        while n < 60:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
            print(pcaddr, n)
            if '192.168.' not in str(pcaddr):
                time.sleep(2)
                n += 1
            else:
                print('IP地址已自动获取成功', n)
                break
        else:
            raise Exception('未获取到地址')
        n = 0
        while n < 30:
            ping = pingTestIP(WAN1_ip)
            if ping != "Y":
                time.sleep(1)
                n += 1
            else:
                break
        else:
            logger.info(u'切换IP后wan口方向 无法ping通wan口')
            logger.info(u'pcIP地址为 %s' % pcaddr)
            raise Exception(u'切换IP后wan口方向 无法ping通wan口')
        logger.info(u'pcIP地址为 %s' % pcaddr)
        WANURL = str('http://' + str(WAN1_ip) + ':8081')
        #使用页面获取的WAN1 ip验证登录
        login.test_enableLoginWeb(self, url=WANURL)
        self.driver.quit()

        #改回lan口方向
        # 调用bat脚本 地址修改为 192.168.34.39 网关192.168.34.1
        os.system('%s' % (batpath + 'changeStaticIP3_34duan.bat'))
        time.sleep(5)
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
            print(pcaddr, n)
            if str(pcaddr) != '192.168.34.39':
                time.sleep(2)
                n += 1
            else:
                print('地址已修改为地址 192.168.34.39', n)
                time.sleep(2)
                break
        else:
            raise Exception('地址修改为192.168.34.39 失败')
        # 更改pc 交换机接口与lan口通
        swconfig.test_WanToLan(self)
        # 将IP改回自动获取 应获取到被测设备下发的地址
        os.system('%s' % (batpath + 'changeDhcpIp.bat'))
        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('未获取到地址')

        logger.info('test_001_openRemote passed')
Exemple #8
0
    def tearDown(self):
        nodata = getAssertText('nodata')

        #删除VPN
        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(1)
        pptpl2tp.click_ok()
        time.sleep(2)
        list_nodata = pptpl2tp.getText_byXpath(pptpl2tp.list_nodata)
        if list_nodata == nodata:
            logger.info(u'R1 VPN 已删除')
        else:
            CapPic(self.driver)
            logger.info(u'R1 VPN删除失败')
            raise Exception(u'R1 VPN删除失败')

        pptpl2tp.click_PPTPGlobalSet()
        time.sleep(0.5)
        pptpl2tp.click_pptpserverC()
        pptpl2tp.click_save()
        time.sleep(1)
        pptpl2tp.click_PPTPGlobalSet()
        time.sleep(0.5)
        pptpSs = pptpl2tp.getAttribute_byXpath(pptpl2tp.pptpserverCs,
                                               'checked')
        if pptpSs == 'true':
            logger.info(u'pptpserver已关闭')
        else:
            CapPic(self.driver)
            logger.info(u'pptpserver未关闭')
            return Exception(u'pptpserver未关闭')
        pptpl2tp.click_l2tpGlobalSet()
        time.sleep(0.5)
        pptpl2tp.click_L2tpserverC()
        pptpl2tp.click_saveSl2tp()
        time.sleep(1)
        pptpl2tp.click_l2tpGlobalSet()
        time.sleep(0.5)
        l2tpSs = pptpl2tp.getAttribute_byXpath(pptpl2tp.L2tpserverCs,
                                               'checked')
        if l2tpSs == 'true':
            logger.info(u'L2tpserver已关闭')
        else:
            CapPic(self.driver)
            logger.info(u'L2tpserver未关闭')
            return Exception(u'L2tpserver未关闭')
        self.driver.quit()

        login.test_enableLoginWeb(self, url=vpnRouteUrl)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(1)
        pptpl2tp.click_ok()
        time.sleep(2)
        try:  #VPN 路由器是中文简体,在测试其他语言版本时,删除后的nodata会不一致
            pptpl2tp.find_list_nodataX()
        except NoSuchElementException:
            CapPic(self.driver)
            logger.info(u'R2 ipsec删除失败')
            raise Exception(u'R2 ipsec删除失败')
        else:
            logger.info(u'R2 ipsec 已删除')
        # list_nodata = pptpl2tp.getText_byXpath(pptpl2tp.list_nodata)
        # if list_nodata == nodata:
        #     logger.info(u'R2 VPN 已删除')
        # else:
        #     CapPic(self.driver)
        #     logger.info(u'R2 VPN删除失败')
        #     raise Exception(u'R2 VPN删除失败')
        self.driver.quit()

        logger.info('tearDown over')
        logger.info('%s' % ('=' * 50))
Exemple #9
0
    def test_004_L2tpclient(self):
        u'''L2tpclient'''

        vpnRouteLan = getweb('vpnRouteLan')
        host = gettelnet('host')
        StateVPN2 = getAssertText('StateVPN2')
        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        # 操作删除 以访已有规则
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            pptpl2tp.find_ok()
        except NoSuchElementException:
            try:
                pptpl2tp.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('VPN隧道列表为空')

        pptpl2tp.click_add()
        time.sleep(2)
        pptpl2tp.click_workMode2()
        pptpl2tp.click_workModel2tp()
        pptpl2tp.input_TunNames('testC')
        pptpl2tp.input_TunNamesIP(vpnRouteWan)
        pptpl2tp.input_userNames('test')
        pptpl2tp.input_password('test')
        pptpl2tp.input_remoteInIp(vpnRouteLan)
        pptpl2tp.input_remoteInIPMask('255.255.255.0')
        pptpl2tp.click_save()
        time.sleep(2)
        self.driver.quit()

        # 另外一台路由器 配置pptp Server
        login.test_enableLoginWeb(self, url=vpnRouteUrl)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        # 操作删除 以访已有规则
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            pptpl2tp.find_ok()
        except NoSuchElementException:
            try:
                pptpl2tp.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('VPN隧道列表为空')

        pptpl2tp.click_l2tpGlobalSet()  #语言问题待修改成xpath
        time.sleep(0.5)
        pptpl2tp.click_L2tpserverEn()
        pptpl2tp.input_priDns('114.114.114.114')
        pptpl2tp.click_save()
        time.sleep(1)
        pptpl2tp.click_l2tpGlobalSet()
        time.sleep(0.5)
        l2tpSs = pptpl2tp.getAttribute_byXpath(pptpl2tp.L2tpserverEs,
                                               'checked')
        if l2tpSs == 'true':
            logger.info(u'L2tpserver已开启')
        else:
            CapPic(self.driver)
            logger.info(u'L2tpserver未开启')
            return Exception(u'L2tpserver未开启')

        pptpl2tp.click_Tunnellist()
        time.sleep(0.5)
        pptpl2tp.click_add()
        time.sleep(1)
        pptpl2tp.click_workMode1()
        pptpl2tp.click_workModel2tp()
        pptpl2tp.input_TunNames('testC')
        seluserType = pptpl2tp.selelement_byName(pptpl2tp.seluserType)
        Select(seluserType).select_by_value('lantolan')
        pptpl2tp.input_userNames('test')
        pptpl2tp.input_password('test')
        pptpl2tp.input_remoteInIp(host)
        pptpl2tp.input_remoteInIPMask('255.255.255.0')
        pptpl2tp.click_saveS()
        time.sleep(2)

        i = 0
        while i < 100:
            pptpl2tp.click_pptpL2tp()
            time.sleep(1)
            list_status = pptpl2tp.getText_byXpath(pptpl2tp.list_status)
            print(list_status)
            if list_status == StateVPN2:
                logger.info(u'L2tp 已建立')
                break
            else:
                time.sleep(3)
                i += 1
        else:
            logger.info(u'L2tp 未建立成功')
            CapPic(self.driver)
            raise Exception(u'L2tp未建立成功')
        self.driver.quit()

        logger.info('test_004_L2tpclient passed')
Exemple #10
0
    def test_001_PPTPserver(self):
        u'''PPTPserver'''

        vpnRouteLan = getweb('vpnRouteLan')
        host = gettelnet('host')
        StateVPN2 = getAssertText('StateVPN2')
        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        # 操作删除 以访已有规则
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            pptpl2tp.find_ok()
        except NoSuchElementException:
            try:
                pptpl2tp.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('VPN隧道列表为空')

        pptpl2tp.click_PPTPGlobalSet()
        time.sleep(0.5)
        pptpl2tp.click_pptpserverEn()
        pptpl2tp.input_priDns('114.114.114.114')
        pptpl2tp.click_save()
        time.sleep(1)
        pptpSs = pptpl2tp.getAttribute_byXpath(pptpl2tp.pptpserverEs,
                                               'checked')
        if pptpSs == 'true':
            logger.info(u'pptpserver已开启')
        else:
            CapPic(self.driver)
            logger.info(u'pptpserver未开启')
            return Exception(u'pptpserver未开启')

        pptpl2tp.click_add()
        time.sleep(1)
        pptpl2tp.click_workMode1()
        pptpl2tp.click_workModepptp()
        pptpl2tp.input_TunNames('testS')
        seluserType = pptpl2tp.selelement_byName(pptpl2tp.seluserType)
        Select(seluserType).select_by_value('lantolan')
        pptpl2tp.input_userNames('test')
        pptpl2tp.input_password('test')
        pptpl2tp.input_remoteInIp(vpnRouteLan)
        pptpl2tp.input_remoteInIPMask('255.255.255.0')
        pptpl2tp.click_saveS()
        time.sleep(2)

        # 从外网配置页面获取WAN1口地址
        wanpage = NetworkConfig_wanpage(self.driver, self.url)
        wanpage.click_NetworkConfig()
        time.sleep(0.5)
        wanpage.click_WANconfig()
        time.sleep(1)
        # WAN1 ip变量赋值,页面读取
        # 判断联网状态
        i = 0
        while i < 21:
            wanpage.click_refresh()
            time.sleep(1)
            list_conState = wanpage.getText_byXpath(wanpage.connectState1)
            print(str(list_conState), i)
            if str(list_conState) != ConnectState:
                time.sleep(3)
                i += 1
            else:
                break
        else:
            CapPic(self.driver)
            logger.info(u"WAN口未连接")
            raise Exception('WAN1 未连接')
        WAN1_ip = str(wanpage.getText_byXpath(wanpage.line1IP))
        # print('WAN1_ip=',WAN1_ip)
        time.sleep(1)
        self.driver.quit()

        # 另外一台路由器 配置pptp Client
        login.test_enableLoginWeb(self, url=vpnRouteUrl)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        # 操作删除 以访已有规则
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            pptpl2tp.find_ok()
        except NoSuchElementException:
            try:
                pptpl2tp.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('VPN隧道列表为空')

        pptpl2tp.click_add()
        time.sleep(2)
        pptpl2tp.click_workMode2()
        pptpl2tp.click_workModepptp()
        pptpl2tp.input_TunNames('testS')
        pptpl2tp.input_TunNamesIP(WAN1_ip)
        pptpl2tp.input_userNames('test')
        pptpl2tp.input_password('test')
        pptpl2tp.input_remoteInIp(host)
        pptpl2tp.input_remoteInIPMask('255.255.255.0')
        pptpl2tp.click_save()
        time.sleep(2)

        i = 0
        while i < 100:
            pptpl2tp.click_pptpL2tp()
            time.sleep(1)
            list_status = pptpl2tp.getText_byXpath(pptpl2tp.list_status)
            print(list_status)
            if list_status == StateVPN2:
                logger.info(u'PPTP 已建立')
                break
            else:
                time.sleep(3)
                i += 1
        else:
            logger.info(u'pptp 未建立成功')
            CapPic(self.driver)
            raise Exception(u'pptp未建立成功')
        self.driver.quit()

        logger.info('test_001_PPTPserver passed')