def _prepare(): #clear qq,wechat and game datax on device to make sure a stable test environment, and then launch the game. env = os.environ.get("PLATFORM_IP") logger = manager.get_logger() lanuch_result = False if env: lanuch_result = _cloud_prepare() else: lanuch_result = _native_prepare() if lanuch_result: #launch success. in general , a game may have a loading phase in which the sdk has not been launched. So we try to connect SDK in a loop. logger.debug("Launch package {0} SUCCESS,try to connect U3DAutomation SDK".format(os.environ["PKGNAME"])) global engine engine = manager.get_engine() version = None for i in range(30): try: version = engine.get_sdk_version() if version: logger.debug(version) manager.save_sdk_version(version) return True except: time.sleep(2) return False
def _prepare(): # 准备工作 # 清理QQ、微信账号,清理游戏数据确保每次启动的逻辑是一样的。然后,拉起游戏 env = os.environ.get("PLATFORM_IP") logger = manager.get_logger() lanuch_result = False if env: lanuch_result = _cloud_prepare() else: lanuch_result = _native_prepare() if lanuch_result: # 拉起成功,通常游戏会有一段过场动画,这时候并不一定会启动我们这边的sdk,我们需要不断的尝试连接SDK。如果,连接成功获取sdk版本号则游戏已经启动 logger.debug("Launch package {0} SUCCESS,try to connect U3DAutomation SDK".format(os.environ["PKGNAME"])) global engine engine = manager.get_engine() version = None for i in range(30): try: version = engine.get_sdk_version() if version: logger.debug(version) manager.save_sdk_version(version) return True except: time.sleep(2) return False
def _prepare(): # 准备工作 # 清理QQ、微信账号,清理游戏数据确保每次启动的逻辑是一样的。然后,拉起游戏 env = os.environ.get("PLATFORM_IP") logger = manager.get_logger() lanuch_result = False if env: lanuch_result = _cloud_prepare() else: lanuch_result = _native_prepare() if lanuch_result: # 拉起成功,通常游戏会有一段过场动画,这时候并不一定会启动我们这边的sdk,我们需要不断的尝试连接SDK。如果,连接成功获取sdk版本号则游戏已经启动 logger.debug( "Launch package {0} SUCCESS,try to connect U3DAutomation SDK". format(os.environ["PKGNAME"])) global engine engine = manager.get_engine() version = None for i in range(30): try: version = engine.get_sdk_version() if version: logger.debug(version) manager.save_sdk_version(version) return True except: time.sleep(2) return False
def get_scene_condition_fun(*name): """ 主要用于random_click,只要有到达符合的scene,random_click就退出 :param name: :return: """ engine = manager.get_engine() def find_need_scene(elements): try: scene = engine.get_scene() if scene in name: return True except: pass return False return find_need_scene
def _prepare(): # 准备工作 # 清理QQ、微信账号,清理游戏数据确保每次启动的逻辑是一样的。然后,拉起游戏 env = os.environ.get("PLATFORM_IP") logger = manager.get_logger() lanuch_result = False if env: lanuch_result = _cloud_prepare() else: lanuch_result = _native_prepare() if lanuch_result: # 拉起成功,通常游戏会有一段过场动画,这时候并不一定会启动我们这边的sdk,我们需要不断的尝试连接SDK。如果,连接成功获取sdk版本号则游戏已经启动 logger.debug( "Launch package {0} SUCCESS,try to connect U3DAutomation SDK". format(os.environ["PKGNAME"])) global engine engine = manager.get_engine() version = None for i in range(30): try: # 开场msdk提示 allow = device.ui_device(className="android.widget.Button") if allow and allow.exists: logger.debug("find popup windows click") allow.click.wait() device.excute_adb("shell input tap 20 20") time.sleep(5) version = engine.get_sdk_version() if version: logger.debug(version) manager.save_sdk_version(version) return True except: time.sleep(2) return False
Tencent is pleased to support the open source community by making GAutomator available. Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://opensource.org/licenses/MIT Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ __author__ = 'minhuaxu [email protected]' import sys, os, time sys.path.append(os.path.abspath(os.path.join(os.getcwd(), ".."))) import wpyscripts.manager as manager engine = manager.get_engine() logger = manager.get_logger() device = manager.get_device() def test_get_display_size(): display_size = device.get_display_size() logger.debug(display_size) rotation = device.get_rotation() logger.debug("Rotation : {0}".format(rotation)) def test_get_top_package_activity(): top_activity = device.get_top_package_activity() logger.debug(top_activity)
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://opensource.org/licenses/MIT Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ __author__ = 'minhuaxu [email protected]' import time import sys import os sys.path.append(os.path.abspath(os.path.join(os.getcwd(), ".."))) import wpyscripts.manager as manager engine = manager.get_engine() logger = manager.get_logger() reporter = manager.get_reporter() def screen_shot_click(element): logger.debug("screen_shot_click") if element is None: return bound = engine.get_element_bound(element) logger.debug(bound) pos_x = bound.x + bound.width / 2 pos_y = bound.y + bound.height / 2 reporter.capture_and_mark(pos_x, pos_y, locator_name=element.object_name) engine.click_position(pos_x, pos_y)
def __init__(self, path): self.engine = manager.get_engine() self.socket = self.engine.socket self.record_file = open(path, "w")