Beispiel #1
0
    def test_reboot1(self):
        u'''重启 - 页面上方'''
        WillReboottips = getAssertText('WillReboottips')

        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        reboot = MaintenancePage(self.driver, self.url)
        reboot.click_headerReboot()
        time.sleep(0.5)
        reboot.click_ok()
        time.sleep(2)
        tips = str(reboot.getText_byClass(reboot.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)  #admin账号登录
        time.sleep(1)
        self.driver.quit()
        logger.info('test_reboot1 passed')
Beispiel #2
0
    def test_errorSoftware(self):
        u'''软件升级 - 验证错误型号'''
        errversion = getweb('errversion')
        updataWarnTips = getAssertText('updataWarnTips')

        errSoftware = (str(tmppath) + str(errversion) + '.bin')
        # 更新一个错误型号 验证无法升级 及提示信息
        software = MaintenancePage(self.driver, self.url)
        #选择文件上传
        self.driver.find_element_by_name('updatesoftware').send_keys(
            errSoftware)
        # software.input_updatesoftware(errSoftware) #定位不到
        time.sleep(1)
        software.click_update()
        time.sleep(1)
        software.click_ok()
        time.sleep(2)
        # 断言提示信息内容正确:代表该项正常
        pageTip = software.getText_byClass(software.pageTip_warn)
        if pageTip != updataWarnTips:
            CapPic(self.driver)
            logger.info(u"升级错误型号 提示信息异常")
            raise Exception('升级错误型号 提示信息异常')
        else:
            print('更新 错误型号版本 验证通过')
        self.driver.quit()
Beispiel #3
0
    def test_reboot2(self):
        u'''重启 - 系统维护页面'''  #系统配置-系统维护-重启设备 页面的重启
        WillReboottips = getAssertText('WillReboottips')

        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        reboot = MaintenancePage(self.driver, self.url)
        reboot.click_sysConfig()
        time.sleep(0.5)
        reboot.click_Maintenance()
        time.sleep(1)
        reboot.click_RebootDevice()
        time.sleep(1)
        reboot.click_reboot()
        time.sleep(1)
        reboot.click_ok()
        time.sleep(1)
        tips = str(reboot.getText_byClass(reboot.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

        self.driver.quit()

        #待重启后验证 登录是否正常
        login.loginWeb(self)  #admin账号登录
        time.sleep(1)
        self.driver.quit()
        print('系统维护页面 设备重启 验证通过')
        logger.info('test_reboot2 passed')
Beispiel #4
0
    def test_001_ManualUpgrade(self):
        u'''手动升级'''
        v2APname = getweb('v2APname')
        v2APoldversion = getweb('v2APoldversion')
        v2APnewversion = getweb('v2APnewversion')
        v1APname = getweb('v1APname')
        v1APoldversion = getweb('v1APoldversion')
        v1APnewversion = getweb('v1APnewversion')
        WillReboottips = getAssertText('WillReboottips')
        OnlineA = getAssertText('OnlineA')
        tmppath = os.path.dirname(os.path.abspath('.')) + '/script/'
        batpath = os.path.dirname(os.path.abspath('.')) + '/script/'

        #等待AP上线
        device = deviceMgmtPage(self.driver, self.url)
        device.click_wirelessExtension()
        time.sleep(0.5)
        device.click_deviceMgmt()
        time.sleep(1)
        x = 0
        while x < 100:
            device.click_refreshtable()
            time.sleep(1)
            list_status1 = device.getText_byXpath(device.list_status1)
            list_status2 = device.getText_byXpath(device.list_status2)
            list_status3 = device.getText_byXpath(device.list_status3)
            list_status4 = device.getText_byXpath(device.list_status4)
            print(list_status1, list_status2, list_status3, list_status4, x)
            if list_status1 == OnlineA and list_status2 == OnlineA and list_status3 == OnlineA and list_status4 == OnlineA:
                print('4台AP均在线', x)
                channel1 = str(
                    device.getAttribute_byXpath(device.list_channel1,
                                                'data-local'))
                channel2 = str(
                    device.getAttribute_byXpath(device.list_channel2,
                                                'data-local'))
                channel3 = str(
                    device.getAttribute_byXpath(device.list_channel3,
                                                'data-local'))
                channel4 = str(
                    device.getAttribute_byXpath(device.list_channel4,
                                                'data-local'))
                print('channel1=', channel1, 'channel2=', channel2,
                      'channel3=', channel3, 'channel4=', channel4, x)
                if channel1 != '' and channel2 != '' and channel3 != '' and channel4 != '':
                    print('4台AP2.4G无线接口已同步', x)
                    break
                else:
                    time.sleep(3)
            else:
                time.sleep(3)
            x = x + 1
        else:
            raise Exception('AP  未能同步2.4G无线接口')
        time.sleep(10)
        #先将WA3000N & WA2520N 单独页面降级
        device.input_search(v2APname)
        device.click_searchB()
        time.sleep(1)
        v2_ip1 = str(device.getText_byXpath(device.list_IP1))
        passurl_v2 = 'http://*****:*****@' + v2_ip1 + '/SoftwareUpdate.asp'  # 在URL里面直接加入用户名和密码
        pathv2 = tmppath + v2APoldversion + '.bin'
        device.input_search(v1APname)
        device.click_searchB()
        time.sleep(1)
        v1_ip4 = str(device.getText_byXpath(device.list_IP1))
        passurl_v1 = 'http://*****:*****@' + v1_ip4 + '/SoftwareUpdate.asp'  # 在URL里面直接加入用户名和密码
        pathv1 = tmppath + v1APoldversion + '.bin'

        # V2降级
        # 新开一个窗口,通过执行js来新开一个窗口
        js = 'window.open("%s");' % passurl_v2
        self.driver.execute_script(js)
        route_handles = self.driver.current_window_handle
        # print('route_handles:',route_handles)  # 输出当前窗口句柄(路由)
        all_handles = self.driver.window_handles  # 获取当前窗口句柄集合(列表类型)
        # print(all_handles)  # 输出句柄集合

        for handle in all_handles:  # 切换窗口(切换到v2)
            if handle != route_handles:
                print('switch to '), handle
                self.driver.switch_to_window(handle)
                v2_handles = self.driver.current_window_handle
                # print('v2_handles:',v2_handles)  # 输出当前窗口句柄(v2)
                break
        try:
            self.driver.get(passurl_v2)
            self.driver.set_page_load_timeout(5)  # selenium超时设置/等待时间过长自动停止
        except TimeoutException:
            print('passurl_v2:', passurl_v2)
            raise Exception('v2 AP1登录失败')
        else:
            apsoftware = APSoftwarePage(self.driver, self.url)
            apsoftware.input_updatesoftware(pathv2)
            time.sleep(1)
            apsoftware.click_uttupdate()
            time.sleep(1)
            self.driver.switch_to.alert.accept()  # 接受警告框
            time.sleep(25)
        # V1降级
        # 再新开一个窗口,通过执行js来新开一个窗口
        js1 = 'window.open("%s");' % passurl_v1
        self.driver.execute_script(js1)
        all_handles2 = self.driver.window_handles  # 获取当前窗口句柄集合(列表类型)
        # print(all_handles2)  # 输出句柄集合

        for handle in all_handles2:  # 切换窗口(切换到v1)
            if handle != route_handles:
                print('switch to '), handle
                self.driver.switch_to_window(handle)
                v1_handles = self.driver.current_window_handle
                # print('v1_handles:', v1_handles)  # 输出当前窗口句柄(v1)
                break
        try:
            self.driver.get(passurl_v1)
            self.driver.set_page_load_timeout(5)  # selenium超时设置/等待时间过长自动停止
        except TimeoutException:
            print('passurl_v1:', passurl_v1)
            raise Exception('v1 AP2登录失败')
        else:
            apsoftware = APSoftwarePage(self.driver, self.url)
            apsoftware.input_updatesoftware(pathv1)
            time.sleep(1)
            apsoftware.click_uttupdate()
            time.sleep(1)
            self.driver.switch_to.alert.accept()  # 接受警告框
            time.sleep(30)
        #web降级后,等待AP上线
        self.driver.switch_to_window(route_handles)
        # 将路由器重启掉(降级后可能会存在mac22不同 导致有同个设备多个离线记录,D525重启很快 放AP后面)
        reboot = MaintenancePage(self.driver, self.url)
        reboot.click_headerReboot()
        time.sleep(1)
        reboot.click_ok()
        time.sleep(2)
        tips = str(reboot.getText_byClass(reboot.u_tim_str))
        self.assertEqual(tips, WillReboottips, msg='点击页面上方重启 操作失败')
        # 等待路由器重启
        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
        self.driver.quit()
        # all_handles = self.driver.window_handles  # 获取当前窗口句柄集合(列表类型)
        # # print(all_handles)  # 输出句柄集合
        # for handle in all_handles:
        #     self.driver.switch_to_window(handle)
        #     self.driver.quit()
        time.sleep(2)
        login.loginWeb2(self)
        self.driver.implicitly_wait(10)
        device = deviceMgmtPage(self.driver, self.url)
        device.click_wirelessExtension()
        time.sleep(0.5)
        device.click_deviceMgmt()
        time.sleep(50)
        x = 0
        while x < 100:
            device.click_refreshtable()
            time.sleep(1)
            list_status1 = device.getText_byXpath(device.list_status1)
            list_status2 = device.getText_byXpath(device.list_status2)
            list_status3 = device.getText_byXpath(device.list_status3)
            list_status4 = device.getText_byXpath(device.list_status4)
            print(list_status1, list_status2, list_status3, list_status4, x)
            if list_status1 == OnlineA and list_status2 == OnlineA and list_status3 == OnlineA and list_status4 == OnlineA:
                print('4台AP均在线', x)
                channel1 = str(
                    device.getAttribute_byXpath(device.list_channel1,
                                                'data-local'))
                channel2 = str(
                    device.getAttribute_byXpath(device.list_channel2,
                                                'data-local'))
                channel3 = str(
                    device.getAttribute_byXpath(device.list_channel3,
                                                'data-local'))
                channel4 = str(
                    device.getAttribute_byXpath(device.list_channel4,
                                                'data-local'))
                print('channel1=', channel1, 'channel2=', channel2,
                      'channel3=', channel3, 'channel4=', channel4, x)
                if channel1 != '' and channel2 != '' and channel3 != '' and channel4 != '':
                    print('4台AP2.4G无线接口已同步', x)
                    break
                else:
                    time.sleep(3)
            else:
                time.sleep(3)
            x = x + 1
        else:
            raise Exception('AP  未能同步2.4G无线接口')

        #手动升级
        apsoftware = APSoftwarePage(self.driver, self.url)
        apsoftware.click_APsoftware()
        time.sleep(1)
        # v1手动升级
        apsoftware.input_serach(v1APname)
        apsoftware.click_serachB()
        time.sleep(1)
        v1_version = str(apsoftware.getText_byXpath(apsoftware.list_version1))
        v1APoldversio2 = v1APoldversion[-12:]  # 截取版本号及日期 如:2.6.4-171110
        self.assertIn(v1APoldversio2, v1_version, msg='v1版本 web页面降级失败')
        apsoftware.click_list_sel1()
        time.sleep(0.2)
        apsoftware.click_upDataLocal()
        time.sleep(2)
        apsoftware.click_chooseFile()
        time.sleep(1)
        # 调用autoIt脚本上传AP版本
        os.system('%s' % (batpath + 'SE_APupdate_WA3000N.exe'))
        time.sleep(2)
        apsoftware.click_demo_upgrade()
        time.sleep(5)
        try:
            self.driver.implicitly_wait(2)
            apsoftware.find_ok()
        except NoSuchElementException:
            pass
        else:
            time.sleep(3)
        time.sleep(8)
        self.driver.implicitly_wait(10)
        # v2手动升级
        apsoftware.input_serach(v2APname)
        apsoftware.click_serachB()
        time.sleep(1)
        v2_version = str(apsoftware.getText_byXpath(apsoftware.list_version1))
        v2APoldversio2 = v2APoldversion[-12:]  #截取版本号及日期 如:2.6.4-171110
        self.assertIn(v2APoldversio2, v2_version, msg='v2版本 web页面降级失败')
        apsoftware.click_list_sel1()
        time.sleep(0.2)
        apsoftware.click_upDataLocal()
        time.sleep(2)
        apsoftware.click_chooseFile()
        time.sleep(1)
        # 调用autoIt脚本上传AP版本
        os.system('%s' % (batpath + 'SE_APupdate_WA2520N.exe'))
        time.sleep(2)
        apsoftware.click_demo_upgrade()
        time.sleep(5)
        try:
            self.driver.implicitly_wait(2)
            apsoftware.find_ok()
        except NoSuchElementException:
            pass
        else:
            time.sleep(3)
        self.driver.implicitly_wait(10)

        #已手动升级,切换到设备管理 等待AP上线
        time.sleep(100)
        self.driver.quit()
        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        time.sleep(0.5)
        print('AP升级中,等待AP上线...')
        device = deviceMgmtPage(self.driver, self.url)
        device.click_wirelessExtension()
        time.sleep(0.5)
        device.click_deviceMgmt()
        time.sleep(1)
        x = 0
        while x < 100:
            device.click_refreshtable()
            time.sleep(1)
            list_status1 = device.getText_byXpath(device.list_status1)
            list_status2 = device.getText_byXpath(device.list_status2)
            list_status3 = device.getText_byXpath(device.list_status3)
            list_status4 = device.getText_byXpath(device.list_status4)
            print(list_status1, list_status2, list_status3, list_status4, x)
            if list_status1 == OnlineA and list_status2 == OnlineA and list_status3 == OnlineA and list_status4 == OnlineA:
                print('4台AP均在线', x)
                channel1 = str(
                    device.getAttribute_byXpath(device.list_channel1,
                                                'data-local'))
                channel2 = str(
                    device.getAttribute_byXpath(device.list_channel2,
                                                'data-local'))
                channel3 = str(
                    device.getAttribute_byXpath(device.list_channel3,
                                                'data-local'))
                channel4 = str(
                    device.getAttribute_byXpath(device.list_channel4,
                                                'data-local'))
                print('channel1=', channel1, 'channel2=', channel2,
                      'channel3=', channel3, 'channel4=', channel4, x)
                if channel1 != '' and channel2 != '' and channel3 != '' and channel4 != '':
                    print('4台AP2.4G无线接口已同步', x)
                    break
                else:
                    time.sleep(3)
            else:
                time.sleep(3)
            x = x + 1
        else:
            raise Exception('AP  未能同步2.4G无线接口')
        #切换回软件管理 确认AP升级后版本
        apsoftware = APSoftwarePage(self.driver, self.url)
        apsoftware.click_APsoftware()
        time.sleep(1)
        apsoftware.input_serach(v2APname)
        apsoftware.click_serachB()
        time.sleep(1)
        v2_version = str(apsoftware.getText_byXpath(apsoftware.list_version1))
        v2APversion2 = v2APnewversion[-12:]  # 截取版本号及日期 如:2.6.4-171110
        self.assertIn(v2APversion2, v2_version, msg='v2版本 手动升级失败')
        apsoftware.input_serach(v1APname)
        apsoftware.click_serachB()
        time.sleep(1)
        v1_version = str(apsoftware.getText_byXpath(apsoftware.list_version1))
        v1APversion2 = v1APnewversion[-12:]  # 截取版本号及日期 如:2.6.4-171110
        self.assertIn(v1APversion2, v1_version, msg='v1版本 手动升级失败')
        self.driver.quit()
        logger.info('test_001_ManualUpgrade passed')
Beispiel #5
0
    def test_oldSoftware1(self, oldversion1=getweb('oldversion1')):
        u'''软件升级 - 更新旧版本测试'''
        # oldversion1 = getweb('oldversion1')
        self.oldversion1 = oldversion1
        UploadingTips = getAssertText('UploadingTips')
        WillReboottips = getAssertText('WillReboottips')

        num = 0
        Expect_Version = ''
        oldversioa1 = oldversion1.split(r'-')
        if len(oldversioa1) == 2:  # eg:'nv640Ev1.5.0-130918'
            Expect_Version = oldversioa1[0] + '-' + oldversioa1[1]
        else:  #eg:'nvA655Wv3.0.0-200116-142208' ; 'TL-BWR-21v3.2.1-200304-171146'
            while num < len(oldversioa1) - 1:
                Expect_Version += oldversioa1[num] + '-'
                num += 1
            else:
                Expect_Version = Expect_Version[:-1]
        # print(Expect_Version)

        # if '.bin' in oldversioa1[1]:
        #     oldversioa2 = oldversioa1[0] + '-' + oldversioa1[1]
        #     Expect_Version = oldversioa2[:-4]
        # else:
        #     Expect_Version = oldversioa1[0] + '-' + oldversioa1[1]

        # 版本上传
        oldSoftware = (str(tmppath) + str(oldversion1) + '.bin')

        self.driver.implicitly_wait(10)
        software = MaintenancePage(self.driver, self.url)
        # 选择文件上传
        self.driver.find_element_by_name('updatesoftware').send_keys(
            oldSoftware)
        # software.input_updatesoftware(oldSoftware)
        time.sleep(1)
        software.click_update()
        time.sleep(1)
        software.click_ok()
        time.sleep(3)
        # 小设备 上传时间较长,判断sleep时间
        tips = str(software.getText_byClass(software.u_tim_str))
        if UploadingTips in tips:
            time.sleep(50)
        elif tips == WillReboottips:
            time.sleep(3)
        # 设备重启时间不一致,做个判断
        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
        self.driver.quit()

        #判断是否升级成功
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        software = MaintenancePage(self.driver, self.url)
        # 进入系统配置-系统维护-系统升级
        software.click_sysConfig()
        time.sleep(0.5)
        software.click_Maintenance()
        time.sleep(1)
        now_Version = str(software.getText_byXpath(software.version))
        if Expect_Version != now_Version:
            CapPic(self.driver)
            logger.info(u"升级旧版本 升级后版本号与升级版本号不一致")
            raise Exception('升级旧版本 升级后版本号与升级版本号不一致')
        else:
            print('更新 旧型号版本 验证通过')
        self.driver.quit()