Exemplo n.º 1
0
    def test_002_license(self):
        u'''登录页面的license'''

        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        maintenance = MaintenancePage(self.driver, self.url)
        maintenance.click_sysConfig()
        time.sleep(0.5)
        maintenance.click_Maintenance()
        time.sleep(1)
        maintenance.click_license()
        time.sleep(1)

        filename = ('//*[@id="iframe5"]/table/tbody/tr[6]/td[2]/input[2]')
        licensefilenow = getlicensefile()
        self.driver.find_element_by_xpath(filename).send_keys(licensefilenow)
        time.sleep(0.5)
        maintenance.click_innerput()
        time.sleep(100)

        self.driver.quit()
        logger.info('test_reboot1 passed')
Exemplo n.º 2
0
    def test_003_configIpmort(self):
        u'''导入配置'''
        nodata = getAssertText('nodata')
        config_xml = getAssertText('config_xml')
        config_xml3 = getAssertText('config_xml3')
        batpath = os.path.dirname(os.path.abspath('.')) + '/script/'
        #先进行配置文件命名修改
        path = os.path.dirname(os.path.abspath('.')) + '/tmp/'  # 配置文件存放(下载)路径
        sys.path.append(r'%s' % path)
        files = os.listdir(r'%s' %
                           path)  #os.listdir(path) 返回path指定的文件夹包含的文件或文件夹的名字的列表
        #通过文件名称判断 修改为指定的文件名
        for filename in files:
            portion = os.path.splitext(filename)  #splitext()用于返回 文件名和扩展名 元组
            # print(portion2)
            if config_xml in str(portion[0]):  #如果文件名种包含"系统配置20"
                if portion[1] == '.xml':  #如果后缀是 .xml
                    newname = config_xml3 + '.xml'
                    #重新组合文件名和后缀名,直接修改名称的话 程序和文件必须在一个目录下
                    filenamedir = (r'%s' % path) + filename
                    newnamedir = (r'%s' % path) + newname
                    #修改文件名称(与autoIt上传脚本中上传的文件名称一致)
                    os.rename(filenamedir, newnamedir)

        #导入配置 验证
        login.loginWeb2(self)
        self.driver.implicitly_wait(10)
        config = MaintenancePage(self.driver, self.url)
        # 进入系统配置-系统维护-配置管理
        config.click_sysConfig()
        time.sleep(0.5)
        config.click_Maintenance()
        time.sleep(1)
        config.click_configuration()
        time.sleep(1)
        # 选中'选择文件' #这里没有取消"导入前恢复出厂设置"按钮
        config.click_chooseFile()
        time.sleep(1)
        #调用autoIt脚本上传组的xml文件
        if config_xml3 == '系统配置3333':
            autoItScript = batpath + 'SE_config_importCn.exe'
        if config_xml3 == 'Systemconfig3333':
            autoItScript = batpath + 'SE_config_importEn.exe'
        os.system('%s' % autoItScript)

        #点击导入
        config.click_innerput()
        time.sleep(1)
        config.click_ok()
        time.sleep(2)
        #取消重启
        config.click_no()
        time.sleep(1)
        #验证导入配置是否成功(通过配置的 今天时间计划)
        timePlan = timePlanPage(self.driver, self.url)
        timePlan.click_sysObj()
        time.sleep(0.5)
        timePlan.click_timePlan()
        time.sleep(1)
        today = str(datetime.date.today())[:-3]  # 获取当前年月(以访测试过程正好隔天,仅取年份月份)
        list_name = str(timePlan.getText_byXpath(timePlan.listName))
        self.assertEqual(list_name, today, msg='配置导入失败')
        time.sleep(1)
        # 删除时间计划
        timePlan = timePlanPage(self.driver, self.url)
        timePlan.click_sysObj()
        time.sleep(0.5)
        timePlan.click_timePlan()
        time.sleep(1)
        timePlan.click_delete()
        time.sleep(1)
        timePlan.click_ok()
        time.sleep(1)
        # 断言
        listtips2 = str(timePlan.getText_byXpath(timePlan.listnodata))
        self.assertEqual(listtips2, nodata, msg='时间计划删除失败')
        print('时间计划已删除')
        self.driver.quit()

        # 删除tmp路径中的xml文件
        call_Firefox.del_config_xml(self)
        logger.info('test_003_configIpmort passed')