def __init__(self, cmd_name): self.cmd_name = cmd_name self.s = start.TestStart().sessionConn(cmd_name) self.d = start.TestStart().connCMD(cmd_name) self.display = self.d.device_info["display"] self.width = self.display['width'] self.height = self.display['height']
def __init__(self, cmd_name): self.cmd_name = cmd_name self.d = start.TestStart().connCMD(cmd_name) self.s = start.TestStart().sessionConn(cmd_name) self.display = self.d.device_info["display"] self.width = self.display['width'] self.height = self.display['height'] self.clickRetrn = comm.DoubleClick() print(f'{self.width}--{self.height}')
def qimiao_threading_excution(self): phone_number = start.TestStart().connectMoblie() with concurrent.futures.ThreadPoolExecutor(max_workers=6) as excutor: if len(phone_number) >= 1: for i in range(len(phone_number)): excutor.submit(self.test_main, phone_number[i]) time.sleep(3) excutor.submit(start.TestStart().save_app_log, phone_number[i], 'qimiao_log') else: print('adb无法连接到手机~~~') print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
def test_main(self, cmd_name): ##APP日志操作 清空 start.TestStart().clear_cache_log(cmd_name) start.TestStart().delete_mobile_log(cmd_name, 'qimiao_log') ## 文件夹 monkey = action.RandomAction(cmd_name) ## 启动APP start.TestStart().openQimiao(cmd_name) print('开始执行monkey测试') while True: monkey.radom_click_liding()
def into_room_exic(self, cmd_name): try: text = start.TestStart().sessionConn(cmd_name)( resourceId='com.qmnl.qmpd:id/okBtn').get_text() print(text) if "知" in text: start.TestStart().sessionConn(cmd_name)( resourceId='com.qmnl.qmpd:id/okBtn').click() print('存在 知道了 弹框---房间已被解散') return False except Exception as e: print('不存在 知道了 弹框') return True
def test_main(self, cmd_name): ##APP日志操作 清空 start.TestStart().clear_cache_log(cmd_name) start.TestStart().delete_mobile_log(cmd_name, 'qimiao_log') ## 文件夹 ## 启动APP start.TestStart().openQimiao(cmd_name) ## 跳过弹框 start.TestStart().jumpFrame(cmd_name) ## 进入房间 随机或者指定 while True: # chat_test.ChatTest(cmd_name).test_chat_main() home_test.HomeTest().test_rooms_main(cmd_name, '卡卡') ## 进入指定的房间再这里写房间名称
def into_room_only(self, cmd_name, room_name): d = start.TestStart().connCMD(cmd_name) print('开始寻找指定的房间~~~') while True: cc = d(resourceId='com.qmnl.qmpd:id/chat_room_title').count for i in range(cc): try: if d(resourceId='com.qmnl.qmpd:id/chat_room_title', instance=i).get_text() == room_name: d(resourceId='com.qmnl.qmpd:id/chat_room_title', instance=i).click() print('已找到指定的房间~~~') return False except Exception as e: print(e) if cc < 2: comm.QimiaoCommnotAction().side(0.712, 0.171, 0.756, 0.829, cmd_name) ## 下拉刷新 print('房间数小于2个下拉数显首页') else: comm.QimiaoCommnotAction().side(0.56, 0.78, 0.5, 0.278, cmd_name) ## 上拉查找 print('正在查找指定房间') return True
def detection_element_exist(self, mode, cmd_name): d = start.TestStart().connCMD(cmd_name) for i in range(5): if (d(resourceId=mode)): return True else: time.sleep(2) return False
def side(self, start_width, start_hight, end_width, end_hight, cmd_name): # d = start.TestStart().connCMD(cmd_name) s = start.TestStart().sessionConn(cmd_name) display = s.device_info['display'] width = display['width'] hight = display['height'] s.swipe(width * start_width, hight * start_hight, width * end_width, hight * end_hight)
def intoRoom(self, cmd_name, room_name): d = start.TestStart().connCMD(cmd_name) ## 获取总共有几个房间 roomNum = d(resourceId='com.qmnl.qmpd:id/chat_room_title').count if roomNum > 3: ## 没办法开发LJ ID都不是唯一的 roomNum = 3 num = random.randint(0, roomNum - 1) ##随机进入一个房间 print("第 -- {} ---个房间".format(num)) d(resourceId='com.qmnl.qmpd:id/chat_room_title', instance=num).click()
def leave_room(self, cmd_name): # 调用两次 防止退出之前进入了私聊页面 end.TestEnd(cmd_name).back_up_level() time.sleep(0.5) end.TestEnd(cmd_name).back_up_level() d = start.TestStart().connCMD(cmd_name) display = d.device_info['display'] width = display['width'] hight = display['height'] d.click(width * 0.686, hight * 0.61)
def test_into_rooms(self, cmd_name, room_name): s = start.TestStart().sessionConn(cmd_name) # d = start.TestStart().connCMD(cmd_name) display = s.device_info["display"] width = display['width'] height = display['height'] for i in range(10): ## 进入前先刷新下 传参(百分比) print('开始刷新首页~~') self.qimiaoCommAction.side(0.712, 0.171, 0.756, 0.829, cmd_name) time.sleep(1) self.qimiaoCommAction.side(0.712, 0.171, 0.756, 0.829, cmd_name) print('刷新首页完成~~') ## 上拉模拟用户滑动 print('开始上拉列表~~') self.qimiaoCommAction.side(0.49, 0.49, 0.482, 0.224, cmd_name) print('上拉列表页完成~~~') if not ac_comm.ActionComm().detection_element_exist( 'com.qmnl.qmpd:id/chat_room_title', cmd_name): print('首页列表元素没有发现----列表为空') ## 随机进入一个房间 into_room.RoomAction().intoRoom(cmd_name, room_name) ## 随机进入 # into_room.RoomAction().into_room_only(cmd_name, room_name) #指定进入某一房间 time.sleep(1) ## 是否存在“知道了”弹框 is_ok = comm.QimiaoCommnotAction().into_room_exic(cmd_name) if is_ok == False: continue else: break time.sleep(10) ## 语聊房内 other_room.OtherRoom(cmd_name).click_up_wheat() ## 房主解散房间 time.sleep(0.5) s.click(width * 0.488, height * 0.614) ## 离开房间 self.qimiaoCommAction.leave_room(cmd_name) for i in range(10): if s(resourceId='com.qmnl.qmpd:id/game_iv'): print("退出营地,成功进入派对首页") break else: time.sleep(2) print(f"第:{i}次 退出营地失败~~~~~~~")
def side(self,start_width, start_hight, end_width, end_hight, cmd_name): s = start.TestStart().sessionConn(cmd_name) s.swipe(start_width, start_hight, end_width, end_hight)
def jieTu(self, cmd_name): s = start.TestStart().sessionConn(cmd_name) screen_name = time.strftime('%Y%m%d_%H%M%S.png') s.screenshot(filename='E:/log/tu/' + screen_name)
def __init__(self, cmd_name): self.cmd_name = cmd_name self.s = start.TestStart().sessionConn(self.cmd_name) self.d = start.TestStart().connCMD(self.cmd_name)
def __init__(self): self.phone_number = start.TestStart().connectMoblie() self.log_path = "E:\qimiao_log"
def __init__(self, cmd_name): self.cmd_name = cmd_name self.chat = chat_group.ChatGroup(self.cmd_name) self.d = start.TestStart().connCMD(cmd_name)
def back_up_level(self): s = start.TestStart().sessionConn(self.cmd_name) s.press("back")