Exemple #1
0
    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_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_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')