示例#1
0
def create_team_game_test(driver, devicename):
    failcount = 10  # 用例中出错后重新执行的次数
    runcount = 1
    num = 1
    elementinfo, deviceid = pubfuc.getiteminfo(driver.desired_capabilities, "zuji")
    while True:
        try:
            if runcount > failcount:
                break
            while num < 50:
                logger.info(f'第{num}次开始球队比赛')
                sleep(3)
                create_team_game(driver, elementinfo)
                driver.find_element_by_xpath(elementinfo['开始比赛']['xpath']).click()
                sleep(2)
                driver.find_element_by_id("android:id/button1").click()
                sleep(10)

                # 结束比赛
                driver.find_element_by_xpath(elementinfo['结束比赛']['xpath']).click()
                sleep(2)
                driver.find_element_by_id("android:id/button1").click()
                sleep(1)
                driver.find_element_by_id("android:id/button1").click()
                sleep(8)

                # 清理视频
                # clean_game_video(driver, elementinfo)

                num += 1
            break
        except Exception as e:
            logger.info(f'第{num}次运行出错')
            err_time = pubfuc.getlocaltime()
            img_file = pubfuc.get_real_dir_path(__file__, f'../testresult/{err_time}-{devicename}.png')
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            logger.info(f'第{runcount}次重跑')
            runcount += 1
            driver.close_app()
            driver.launch_app()
            logger.info(pubfuc.getlocaltime())
            sleep(20)
示例#2
0
def joinandleaveroom(driver,roomid,devicename,packagename):
    suceess_flag = True
    num = 1
    elementinfo,deviceid = pubfuc.getiteminfo(driver.desired_capabilities,packagename)

    while suceess_flag:
        try:
            while num<1000:
                behavior.findroomid(driver, elementinfo, roomid)
                behavior.joinroom(driver,elementinfo)
                behavior.leaveroom(driver,elementinfo)
                num+1

        except Exception as e:
            print('error')
            #logger.error(f'第{num}次运行出错,设备是:{devicename}')
            sleep(3)
            driver.close_app()
            driver.launch_app()
示例#3
0
def changerole(driver, roomid, devicename):
    failcount = 5 # 用例中出错后重新执行的次数
    runcount = 1
    success_flag = True
    num = 1
    devicedriverinfo = driver.desired_capabilities  # 获取正在运行的设备的参数设置
    elementinfo, deviceid = pubfuc.getiteminfo(devicedriverinfo)
    while True:
        try:
            if runcount > failcount:
                break
            if 'RoomI' not in driver.page_source:
                chooseroomtype(driver, elementinfo)  # 选择多人群聊
            joinroom(driver, elementinfo, roomid)  # 加入房间
            sleep(10)
            if elementinfo['离开房间']['id'] not in driver.page_source:
                raise RuntimeError('加入房间失败')
            while num < 1001:
                if num % 10 == 0:
                    logger.info(f"第{num}次{devicename}切换角色")
                driver.find_element_by_id(elementinfo['切换角色']['id']).click()
                sleep(6)
                num += 1
            driver.find_element_by_id(elementinfo['离开房间']['id']).click()
            break
        except Exception as e:
            logger.info(f'第{num}次运行出错,设备是:{devicename}')
            err_time = pubfuc.getlocaltime()
            # xml_file = pubfuc.get_real_dir_path(__file__, f'../testresult/{err_time}-{devicename}.xml')
            # with open(xml_file, 'a') as f:
            #     f.write(driver.page_source)
            img_file = pubfuc.get_real_dir_path(__file__, f'../testresult/{err_time}-{devicename}.png')
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            if not success_flag:
                return
            logger.info(f'第{runcount}次重跑')
            runcount += 1
            driver.close_app()
            driver.launch_app()
            autopuloadlog(driver, devicedriverinfo, devicename, elementinfo)
示例#4
0
def startpkroomios(driver, devicename):
    failcount = 1  # 用例中出错后重新执行的次数
    runcount = 1
    success_flag = True
    num = 1
    devicedriverinfo = driver.desired_capabilities  # 获取正在运行的设备的参数设置
    elementinfo, deviceid = pubfuc.getiteminfo(devicedriverinfo)
    appid = devicedriverinfo['bundleId']
    while success_flag:
        try:
            if runcount > failcount:
                break
            if 'RoomI' not in driver.page_source:
                print(driver.page_source)
                chooseroomtype(driver, elementinfo, '主播PK')  # 选择PK
                startnewroom(driver, elementinfo)  # 创建
            while num < 100:
                logger.info(f'设备{devicename}第{num}次选择房间PK')
                #startnewroom(driver, elementinfo)  # 创建
                #print(driver.page_source)

                driver.find_element_by_xpath("//XCUIElementTypeButton[@name='combineRoom']").click()
                sleep(3)

                driver.find_element_by_xpath("//XCUIElementTypeStaticText[@name='RoomId : 3165']").click()
                sleep(3)
                driver.find_element_by_xpath("//XCUIElementTypeButton[@name='combineRoom']").click()

                sleep(3)
                num += 1
            driver.find_element_by_id(elementinfo['离开房间']['id']).click()
            break
        except Exception as e:
            logger.info(f'第{num}次运行出错,设备是:{devicename}')
            logger.info(driver.page_source)
            img_file = Path(__file__).cwd().parent / 'testresult' / f'{pubfuc.getlocaltime()}-{devicename}.png'
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            logger.info(f'第{runcount}次重跑')
            runcount += 1
            driver.activate_app(appid)
示例#5
0
def login_logout_test(driver, devicename):
    failcount = 3  # 用例中出错后重新执行的次数
    runcount = 1
    num = 1
    elementinfo, deviceid = pubfuc.getiteminfo(driver.desired_capabilities, 'zuji')
    while True:
        try:
            if runcount > failcount:
                break
            sleep(3)
            driver.find_element_by_xpath(elementinfo['我的']['xpath']).click()
            sleep(1)
            if '请登录' in driver.page_source:
                driver.find_element_by_xpath("//android.widget.TextView[@text='请登录']").click()
            else:
                logout(driver)
            while num < 501:
                logger.info(f'第{num}次登录')
                sleep(2)
                loginbyphonenumber(driver)
                sleep(2)
                driver.tap([[200, 200]])
                logout(driver)
                num += 1
            sleep(2)
            # 为保证接下来用例正常运行,测试完登录功能后登录账户
            loginbyphonenumber(driver)
            break
        except Exception as e:
            logger.info(f'第{num}次运行出错,设备是:{devicename}')
            err_time = pubfuc.getlocaltime()
            img_file = pubfuc.get_real_dir_path(__file__, f'../testresult/{err_time}-{devicename}.png')
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            logger.info(f'第{runcount}次重跑')
            runcount += 1
            driver.close_app()
            driver.launch_app()
            logger.info(pubfuc.getlocaltime())
            sleep(20)
示例#6
0
def audiojoinroom(driver,devicename,roomid):
    fail_count = 5  # 用例中出错后重新执行的次数
    run_count = 1
    success_flag = True
    num = 1
    device_driver_info = driver.desired_capabilities  # 获取正在运行的设备的参数设置
    elementinfo, deviceid = pubfuc.getiteminfo(device_driver_info)
    print(roomid)
    while success_flag:
        try:
            if run_count > fail_count:
                break
            while num < 501:
                if 'RoomI' not in driver.page_source:
                    driver.find_element_by_xpath("//android.widget.TextView[@text='游戏连麦']").click()
                    sleep(10)
                    #print(driver.page_source)
                    driver.find_element_by_xpath("//android.widget.TextView[@text='纯音频群聊']").click()
                    sleep(5)
                if num % 10 == 0:
                    logger.info(f"第{num}次{devicename}加入房间")
                joinroom(driver, elementinfo, roomid, False)
                sleep(5)
                driver.find_element_by_id(elementinfo['离开房间']['id']).click()
                sleep(6)
                num += 1
            break
        except Exception as e:
            logger.error(f'第{num}次运行出错,设备是:{devicename}')
            # print(driver.page_source)
            img_file = pubfuc.get_real_dir_path(__file__, f'../testresult/{pubfuc.getlocaltime()}-{devicename}.png')
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            if not success_flag:
                return
            logger.info(f'第{run_count}次重跑')
            run_count += 1
            driver.close_app()
            driver.launch_app()
            autopuloadlog(driver, device_driver_info, devicename, elementinfo)
示例#7
0
def startgameroom(driver, devicename):
    failcount = 1  # 用例中出错后重新执行的次数
    runcount = 1
    num = 1
    devicedriverinfo = driver.desired_capabilities  # 获取正在运行的设备的参数设置
    elementinfo, deviceid = pubfuc.getiteminfo(devicedriverinfo)
    subprocess.call(f"adb -s {deviceid} shell rm /sdcard/powerinfo/*", shell=True)  # 测试前清理日志
    while True:
        try:
            if runcount > failcount:
                break
            if 'RoomI' not in driver.page_source:
                el = elementinfo['多人群聊']['xpath']
                el = re.sub('多人群聊', '游戏连麦', el)
                driver.find_element_by_xpath(el).click()
                sleep(3)
                driver.find_element_by_xpath("//android.widget.TextView[@text='录屏直播']").click()
                sleep(1)
                startnewroom(driver, elementinfo, True)  # 创建
            while num < 301:
                print(f'设备{devicename}第{num}次选择房间PK')
                if num % 10 == 0:
                    logger.info(f'设备{devicename}第{num}次选择房间PK')
                driver.background_app(5)
                sleep(10)
                driver.find_element_by_id(elementinfo['离开房间']['id'])
                # sleep(30)
                num += 1
            driver.find_element_by_id(elementinfo['离开房间']['id']).click()
            break
        except Exception as e:
            logger.info(f'第{num}次运行出错,设备是:{devicename}')
            # logger.info(driver.page_source)
            img_file = Path(__file__).cwd().parent / 'testresult' / f'{pubfuc.getlocaltime()}-{devicename}.png'
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            logger.info(f'第{runcount}次重跑')
            runcount += 1
示例#8
0
    def test_003_DokiDemo_加入切后台操作(self):
        logger.info('test_003_DokiDemo_创建加入房间')
        driver_A = self.driverlist[0]   # 主播A
        failcount = 3  # 用例中出错后重新执行的次数
        runcount = 1
        num = 1
        elementinfo, deviceid = pubfuc.getiteminfo(driver_A.desired_capabilities, 'QSDoki')
        while True:
            try:
                # 进行PK
                print(f'第{num}次加入房间')
                for i in range(15):
                    dokidemo_behavior.join_doki_room(driver_A, elementinfo, self.roomid)
                    sleep(5)
                    driver_A.find_element_by_id(elementinfo['离开房间']['id']).click()
                    sleep(3)
                dokidemo_behavior.join_doki_room(driver_A, elementinfo, self.roomid)
                sleep(5)
                for i in range(15):
                    driver_A.background_app(5)
                    sleep(10)
                driver_A.find_element_by_id(elementinfo['离开房间']['id']).click()
                sleep(3)
                num += 1
                if num > 21 or runcount > failcount:
                    break

            except Exception as e:
                logger.info(f'第{num}次运行出错,设备是:{self.devicename}')
                # print(driver.page_source)
                img_file = pubfuc.get_real_dir_path(__file__, f'../testresult/{pubfuc.getlocaltime()}-{self.devicename[0]}.png')
                driver_A.save_screenshot(str(img_file))
                sleep(3)
                logger.error(e.args[0], exc_info=True)
                logger.info(f'第{runcount}次重跑')
                runcount += 1
                driver_A.close_app()
                driver_A.launch_app()
示例#9
0
def lockscreen(driver, roomid, devicename):
    failcount = 5  # 用例中出错后重新执行的次数
    runcount = 1
    num = 1
    device_driver_info = driver.desired_capabilities  # 获取正在运行的设备的参数设置
    elementinfo, deviceid = pubfuc.getiteminfo(device_driver_info)
    while True:
        try:
            if runcount > failcount:
                break
            if 'RoomI' not in driver.page_source:
                chooseroomtype(driver, elementinfo)  # 选择多人群聊
            # startnewroom(driver, elementinfo)  # 加入房间
            joinroom(driver, elementinfo, roomid)
            sleep(10)
            while num < 1001:
                if num % 10 == 0:
                    logger.info(f"第{num}次{devicename}锁屏")
                driver.lock(5)
                sleep(3)
                # 锁屏回来后,查看离开房间按钮是否可用,确定正确切回了前台
                driver.find_element_by_id(elementinfo['离开房间']['id']).get_attribute('enabled')
                # logger.info(f"离开房间按钮是否可用:{back_is_enable}")
                num += 1
            driver.find_element_by_id(elementinfo['离开房间']['id']).click()
            break
        except Exception as e:
            logger.info(f'第{num}次运行出错,设备是:{devicename}')
            # print(driver.page_source)
            img_file = pubfuc.get_real_dir_path(__file__, f'../testresult/{pubfuc.getlocaltime()}-{devicename}.png')
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            logger.info(f'第{runcount}次重跑')
            runcount += 1
            driver.close_app()
            driver.launch_app()
            autopuloadlog(driver, device_driver_info, devicename, elementinfo)
示例#10
0
def edit_team_name_test(driver, devicename):
    failcount = 10  # 用例中出错后重新执行的次数
    runcount = 1
    num = 1
    team_name = "t1"
    new_team_name = "t10"
    elementinfo, deviceid = pubfuc.getiteminfo(driver.desired_capabilities, "zuji")
    while True:
        try:
            if runcount > failcount:
                break
            while num < 100:
                logger.info(f'第{num}次修改队名')
                sleep(3)
                browse_team(driver, elementinfo)
                select_team(driver, team_name)
                edit_team_name(driver, elementinfo, team_name, new_team_name)
                sleep(2)
                back_android(driver)
                sleep(2)
                a = new_team_name
                new_team_name = team_name
                team_name = a
                num += 1
            break
        except Exception as e:
            logger.info(f'第{num}次运行出错')
            err_time = pubfuc.getlocaltime()
            img_file = pubfuc.get_real_dir_path(__file__, f'../testresult/{err_time}-{devicename}.png')
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            logger.info(f'第{runcount}次重跑')
            runcount += 1
            driver.close_app()
            driver.launch_app()
            logger.info(pubfuc.getlocaltime())
            sleep(20)
示例#11
0
def creatroom(driver, devicename, packagename):
    suceess_flag = True
    num = 1
    elementinfo, deviceid = pubfuc.getiteminfo(driver.desired_capabilities,
                                               packagename)

    while suceess_flag:
        try:
            behavior.choosetype(driver, elementinfo)
            while num < 1000:
                behavior.creatroom(driver, elementinfo)
                behavior.leaveroom(driver, elementinfo)
                num + 1

        except Exception as e:
            print('error')
            # logger.error(f'第{num}次运行出错,设备是:{devicename}')
            sleep(3)
            driver.close_app()
            driver.launch_app()


#def startPK
示例#12
0
def startpkroomandroid_analysis(driver, driver_A, devicename, roomid, uid):
    failcount = 1  # 用例中出错后重新执行的次数
    runcount = 1
    num = 1
    devicedriverinfo = driver.desired_capabilities  # 获取正在运行的设备的参数设置
    elementinfo, deviceid = pubfuc.getiteminfo(devicedriverinfo)
    subprocess.call(f"adb -s {deviceid} shell rm /sdcard/powerinfo/*", shell=True)  # 测试前清理日志
    while True:
        try:
            if runcount > failcount:
                break
            if 'RoomI' not in driver.page_source:
                chooseroomtype(driver, elementinfo, '主播 PK')  # 选择PK
                startnewroom(driver, elementinfo)  # 创建
            while num < 201:
                if num % 10 == 0:
                    logger.info(f'设备{devicename}第{num}次选择房间PK')
                chooseroompk(driver, elementinfo, roomid)
                driver_A.find_element_by_id(elementinfo['离开房间']['id'])  # 查找一下离开按钮,防止另一台手机超时退出房间
                if num % 20 == 0:  # 20次分析一次日志,否则日志太多,文件会更新
                    driver.find_element_by_id(elementinfo['离开房间']['id']).click()
                    analysis_pk_success(roomid, uid, deviceid, devicename)
                    startnewroom(driver, elementinfo)
                num += 1
            driver.find_element_by_id(elementinfo['离开房间']['id']).click()
            break
        except Exception as e:
            logger.info(f'第{num}次运行出错,设备是:{devicename}')
            # logger.info(driver.page_source)
            img_file = Path(__file__).cwd().parent / 'testresult' / f'{pubfuc.getlocaltime()}-{devicename}.png'
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            logger.info(f'第{runcount}次重跑')
            analysis_pk_success(roomid, uid, deviceid, devicename)
            runcount += 1
示例#13
0
def switchwifi(driver, roomid, devicename):
    failcount = 10  # 用例中出错后重新执行的次数
    runcount = 1
    num = 1
    devicedriverinfo = driver.desired_capabilities  # 获取正在运行的设备的参数设置
    elementinfo, deviceid = pubfuc.getiteminfo(devicedriverinfo)
    while True:
        try:
            if runcount > failcount:
                break
            if 'RoomI' not in driver.page_source:
                chooseroomtype(driver, elementinfo)  # 选择多人群聊
            joinroom(driver, elementinfo, roomid)  # 加入房间
            sleep(10)
            if elementinfo['离开房间']['id'] not in driver.page_source:
                raise RuntimeError('加入房间失败')
            while num < 1001:
                if num % 10 == 0:
                    logger.info(f"第{num}次{devicename}断网10s左右恢复")
                switch_wifi(driver, 6)
                driver.find_element_by_id(elementinfo['离开房间']['id']).get_attribute('enabled')
                num += 1
            driver.find_element_by_id(elementinfo['离开房间']['id']).click()
            break
        except Exception as e:
            logger.info(f'第{num}次运行出错,设备是:{devicename}')
            err_time = pubfuc.getlocaltime()
            img_file = pubfuc.get_real_dir_path(__file__, f'../testresult/{err_time}-{devicename}.png')
            driver.save_screenshot(str(img_file))
            sleep(3)
            logger.error(e.args[0], exc_info=True)
            logger.info(f'第{runcount}次重跑')
            runcount += 1
            driver.close_app()
            driver.launch_app()
            autopuloadlog(driver, devicedriverinfo, devicename, elementinfo)
示例#14
0
def createnewparty(driver):
    caps = driver.desired_capabilities
    elementinfo, deviceid = pubfuc.getiteminfo(caps, 'TongZhuoHaiWai')
    size = driver.get_window_size()
    driver.find_element_by_xpath(elementinfo['chat']['xpath']).click()
    sleep(2)
    driver.find_element_by_id(elementinfo['加号']['id']).click()
    sleep(3)
    driver.tap([[size['width']/2 + 200, 270]])
    sleep(2)
    driver.find_element_by_id(elementinfo['random_roomtitile']['id']).click()
    sleep(3)
    driver.find_element_by_xpath(elementinfo['create']['xpath']).click()
    sleep(3)
    driver.find_element_by_xpath(elementinfo['invite']['xpath']).click()
    sleep(1)
    driver.find_element_by_xpath(elementinfo['invite_friends']['xpath']).click()
    sleep(1)
    driver.find_element_by_id(elementinfo['invite_search']['id']).send_keys('loy')
    sleep(1)
    driver.find_element_by_id(elementinfo['invite_select']['id']).click()
    sleep(1)
    driver.find_element_by_xpath("//android.widget.Button[@text='Done(1)']").click()
    sleep(1)
示例#15
0
def startpusha50(driver, device_name):
    failcount = 5  # 用例中出错后重新执行的次数
    runcount = 1
    success_flag = True
    num = 1
    caps = driver.desired_capabilities
    appid = caps['bundleId']
    elementinfo, deviceid = pubfuc.getiteminfo(caps, 'A50')
    try:
        print(driver.get_window_size())
        isdown = driver.find_element_by_xpath(elementinfo['uploadlog']['xpath']).is_displayed()
        print(isdown)
        if "稍后提醒我" in driver.page_source:
            driver.find_element_by_xpath("//XCUIElementTypeButton[@name='稍后提醒我']").click()
        elif "稍后" in driver.page_source:
            driver.find_element_by_xpath("//XCUIElementTypeButton[@name='稍后']").click()
        while not isdown:
            driver.execute_script("mobile: dragFromToForDuration",
                                  {'fromX': 10, 'fromY': 300, 'toX': 10, 'toY': 50, 'duration': 1})
            isdown = driver.find_element_by_xpath(elementinfo['uploadlog']['xpath']).is_displayed()
        sleep(5)
        # logger.info(f"第{num}次{device_name}开始上传日志")
        # size = driver.get_window_size()
        while True:
            logger.info(f"第{num}次{device_name}加入房间")
            driver.find_element_by_id('START').click()
            sleep(60)
            # driver.find_element_by_id('Music').click()
            # backiosapp(driver, size, appid)
            # sleep(300)
            driver.find_element_by_id('Back').click()
            sleep(5)
            # if num % 50 == 0:
            #     logger.info(f"第{num}次{device_name}开始上传日志")
            #     uploadlog(driver, elementinfo)
            #     cleanlog(driver, elementinfo)
            #     downloadfiles = pubfuc.download_file_from_server('A50')
            #     for file in downloadfiles:
            #         extra_dir = pubfuc.extrafile(file)
            #         for f in os.listdir(extra_dir):
            #             filepath = os.path.join(extra_dir, f)
            #             print(filepath)
            #             if 'pslstreaming' in f:
            #                 logger.info('\n推流失败connect为1的结果:')
            #                 pubfuc.parselog(filepath, 'connect=-1')
            num += 1
            if num > 501 or runcount > failcount:
                break
    except Exception as e:
        runcount += 1
        logger.info(f'第{num}次{device_name}运行出错')
        logger.info(f'第{runcount}次重跑')
        # logger.info(driver.page_source)
        img_file = Path(__file__).cwd().parent / 'testresult' / f'{pubfuc.getlocaltime()}-{device_name}.png'
        driver.save_screenshot(str(img_file))
        sleep(5)
        logger.error(e.args[0], exc_info=True)
        driver.activate_app(appid)
        if not success_flag:
            return
        # driver.terminate_app(appid)
        # driver.launch_app()
    finally:
        # return
        if num % 50 != 0:
            logger.info(f"第{num}次{device_name}开始上传日志")
            uploadlog(driver, elementinfo)
            cleanlog(driver, elementinfo)
            downloadfiles = pubfuc.download_file_from_server('A50')
            for file in downloadfiles:
                extra_dir = pubfuc.extrafile(file)

                for f in os.listdir(extra_dir):
                    filepath = os.path.join(extra_dir, f)
                    if 'pslstreaming' in f:
                        logger.info('\n推流失败connect为1的结果:')
                        pubfuc.parselog(filepath, 'connect=-1')
示例#16
0
def startpushp31link191(driver):
    failcount = 10  # 用例中出错后重新执行的次数
    runcount = 1
    success_flag = True
    num = 1
    caps = driver.desired_capabilities
    elementinfo, deviceid = pubfuc.getiteminfo(caps, 'A50')
    size = driver.get_window_size()
    print(size)
    try:
        if "稍后提醒我" in driver.page_source:
            driver.find_element_by_xpath("//XCUIElementTypeButton[@name='稍后提醒我']").click()
        while True:
            uploadisvisiable = driver.find_element_by_xpath(elementinfo['uploadlog']['xpath']).is_displayed()
            if not uploadisvisiable:
                driver.execute_script("mobile: dragFromToForDuration",
                                      {'fromX': size['width']-10, 'fromY': size['height']-50, 'toX': size['width']-10,
                                       'toY': 50, 'duration': 1})
            elif uploadisvisiable:
                break
        sleep(5)
        while True:
            logger.info(f"第{num}次{deviceid}加入房间")
            driver.find_element_by_id('Save Config').click()
            sleep(2)
            driver.find_element_by_id('START').click()
            sleep(15)
            # backiosapp(driver, size, appid)
            driver.find_element_by_id('STOP').click()
            sleep(5)
            if num % 3000 == 0:
                uploadlog(driver, elementinfo)
                cleanlog(driver, elementinfo)
                downloadfiles = pubfuc.download_file_from_server('P31Link')
                print(downloadfiles)
                for file in downloadfiles:
                    print(file)
                    extra_dir = pubfuc.extrafile(file)
                    print(extra_dir)
                    for f in os.listdir(extra_dir):
                        if 'pslstreaming' in f:
                            logger.info('\n推流失败connect为1的结果:\n')
                            pubfuc.parselog(f, 'connect=-1')
                        elif 'psdemux'in f:
                            logger.info('\npsmoe为\n')
                            pubfuc.parselog(f, 'psmode')
                            logger.info('\nbps为0的结果\n')
                            pubfuc.parselog(f, 'bps 0')
            num += 1
            if num > 300 or runcount > failcount:
                break
    except Exception as e:
        runcount += 1
        logger.info(f'第{num}次{deviceid}运行出错')
        logger.info(f'第{runcount}次重跑')
        # logger.info(driver.page_source)
        img_file = Path(__file__).cwd().parent / 'testresult' / f'{pubfuc.getlocaltime()}-{deviceid}.png'
        driver.save_screenshot(str(img_file))
        sleep(5)
        logger.error(e.args[0], exc_info=True)
        if not success_flag:
            return
        # driver.terminate_app(appid)
        # driver.launch_app()
    finally:
        if num % 30 != 0:
            uploadlog(driver, elementinfo)
            cleanlog(driver, elementinfo)
示例#17
0
def f2fPushSiri(driver, device_name):
    failcount = 10  # 用例中出错后重新执行的次数
    runcount = 1
    success_flag = True
    num = 1
    caps = driver.desired_capabilities
    appid = caps['bundleId']
    elementinfo, deviceid = pubfuc.getiteminfo(caps, '直面')
    try:
        if "稍后提醒我" in driver.page_source:
            driver.find_element_by_xpath("//XCUIElementTypeButton[@name='稍后提醒我']").click()
        elif "稍后" in driver.page_source:
            driver.find_element_by_xpath("//XCUIElementTypeButton[@name='稍后']").click()
        sleep(5)
        # if num ==1:
            # uploadlog(driver, elementinfo)
            # cleanlog(driver, elementinfo)
            # logger.info(f'第{runcount}次启动截图')
            # logger.info(driver.page_source)
            # img_file = Path(__file__).cwd().parent / 'testresult' / f'{pubfuc.getlocaltime()}-{device_name}.png'
            # driver.save_screenshot(str(img_file))
            # sleep(5)
        # size = driver.get_window_size()
        bundleid = driver.capabilities['bundleId']
        size = driver.get_window_size()
        driver.find_element_by_xpath(elementinfo['加入会议']['xpath']).click()
        sleep(1)
        TouchAction(driver).tap(x=180, y=121).perform()  # 输入会议ID
        sleep(3)
        TouchAction(driver).tap(x=66, y=528).perform()  # 4
        TouchAction(driver).tap(x=185, y=526).perform()  # 5
        TouchAction(driver).tap(x=310, y=527).perform()  # 6
        sleep(1)
        TouchAction(driver).tap(x=183, y=276).perform()  # 加入会议
        sleep(5)
        while success_flag:
            logger.info(f"第{num}次{device_name}开siri")
            print(f"第{num}次{device_name}开siri")


            TouchAction(driver).tap(x=341, y=634).perform()
            sleep(2)
            TouchAction(driver).tap(x=101, y=488).perform() # iphone辅助功能按键放置在右下角
            sleep(6)

            driver.activate_app(bundleid)
            sleep(15)
            # 切后台回来后,查看离开房间按钮是否可用,确定正确切回了前台
            # y = driver.page_source
            # x = re.findall('临时会议.+\d+', y)[0]
            # z = re.findall('\d+', x)[0];
            # print(z)
            # back_is_enable = driver.find_element_by_xpath(
            #     f'(//XCUIElementTypeOther[@name="临时会议-{z}"])[1]/XCUIElementTypeOther[1]').get_attribute('enabled')
            back_is_enable = driver.find_element_by_xpath(elementinfo['会议界面返回按钮']['xpath']).get_attribute('enabled')
            logger.info(f"离开房间按钮是否可用:{back_is_enable}")


            # uploadlog(driver, elementinfo)
            # cleanlog(driver, elementinfo)
            # pubfuc.download_file_from_server('A50')
            #if num % 50 == 0:
                #logger.info(f"第{num}次{device_name}开始上传日志")
                #uploadlog(driver, elementinfo)
                #cleanlog(driver, elementinfo)
                #downloadfiles = pubfuc.download_file_from_server('A50')
            num += 1
            if num > 500 or runcount > failcount:
                success_flag = False
    except Exception as e:
        runcount += 1
        logger.info(f'第{num}次{device_name}运行出错')
        logger.info(f'第{runcount}次重跑')
        # logger.info(driver.page_source)
        img_file = Path(__file__).cwd().parent / 'testresult' / f'{pubfuc.getlocaltime()}-{device_name}.png'
        driver.save_screenshot(str(img_file))
        sleep(5)
        logger.error(e.args[0], exc_info=True)
        driver.activate_app(appid)
        if not success_flag:
            return
        driver.close_app()
        driver.launch_app()
示例#18
0
def startpushf2f(driver, device_name):
    failcount = 10  # 用例中出错后重新执行的次数
    runcount = 1
    success_flag = True
    num = 1
    caps = driver.desired_capabilities
    appid = caps['bundleId']
    elementinfo, deviceid = pubfuc.getiteminfo(caps, '直面')
    try:
        if "稍后提醒我" in driver.page_source:
            driver.find_element_by_xpath("//XCUIElementTypeButton[@name='稍后提醒我']").click()
        elif "稍后" in driver.page_source:
            driver.find_element_by_xpath("//XCUIElementTypeButton[@name='稍后']").click()
        sleep(5)
        # if num ==1:
            # uploadlog(driver, elementinfo)
            # cleanlog(driver, elementinfo)
            # logger.info(f'第{runcount}次启动截图')
            # logger.info(driver.page_source)
            # img_file = Path(__file__).cwd().parent / 'testresult' / f'{pubfuc.getlocaltime()}-{device_name}.png'
            # driver.save_screenshot(str(img_file))
            # sleep(5)
        # size = driver.get_window_size()
        while success_flag:
            logger.info(f"第{num}次{device_name}召开会议")
            print(f"第{num}次{device_name}召开会议")
            driver.find_element_by_xpath(elementinfo['召开会议']['xpath']).click()
            sleep(3)
            driver.find_element_by_xpath(elementinfo['召开会议2']['xpath']).click()
            sleep(5)
            # y = driver.page_source
            # x=re.findall('临时会议.+\d+', y)[0]
            # z=re.findall('\d+', x)[0];
            # print(z)
            # driver.find_element_by_xpath(f'(//XCUIElementTypeOther[@name="临时会议-{z}"])[1]/XCUIElementTypeOther[1]').click()
            driver.find_element_by_xpath(elementinfo['退出会议']['xpath']).click()
            sleep(3)
            driver.find_element_by_xpath(elementinfo['结束会议']['xpath']).click()
            sleep(3)
            driver.find_element_by_xpath(elementinfo['召开会议-返回']['xpath']).click()
            # uploadlog(driver, elementinfo)
            # cleanlog(driver, elementinfo)
            # pubfuc.download_file_from_server('A50')
            #if num % 50 == 0:
                #logger.info(f"第{num}次{device_name}开始上传日志")
                #uploadlog(driver, elementinfo)
                #cleanlog(driver, elementinfo)
                #downloadfiles = pubfuc.download_file_from_server('A50')
            num += 1
            if num > 100 or runcount > failcount:
                success_flag = False
    except Exception as e:
        runcount += 1
        logger.info(f'第{num}次{device_name}运行出错')
        logger.info(f'第{runcount}次重跑')
        # logger.info(driver.page_source)
        img_file = Path(__file__).cwd().parent / 'testresult' / f'{pubfuc.getlocaltime()}-{device_name}.png'
        driver.save_screenshot(str(img_file))
        sleep(5)
        logger.error(e.args[0], exc_info=True)
        driver.activate_app(appid)
        if not success_flag:
            return
        driver.close_app()
        driver.launch_app()