a sample to touch engine element ''' def touch_test(): ga2.touch_element(ga2.By.NAME_IN_ENGINE, "/Canvas/Panel/FindElements") ''' a sample to get the screenshot ''' def screenshot_test(): image = device.screenshot() cv2.imwrite("test.jpg", image) device = ga2.init_device(ga2.DeviceType.DEVICE_IOS, udid) # get the instance of device ga2.launch_app( TEST_PKG_NAME ) #if you are going to test a specific scene, just comment out this line. ga2.init_engine_sdk(enginetype=ga2.EngineType.Unity) wait_test() touch_test() random_travel() screenshot_test() wait_fail_test() # device.iproxy.removeAllForwards()
# * password : the qq/wechat password # # ### output # returns ERR\_SUCCEED(0) if succeed ''' a sample to login wechat/qq, if you want to use wda client to do automation on native app , the login_tencent module is a sample. ''' def login_test(): ga2_contrib.login_tencent(wechatname, wechatpwd) #if you want to test specefic scene, call connect_to_engine instead of launch device = ga2.init_device(ga2.DeviceType.DEVICE_IOS, udid) #get the instance of device ga2.launch_app(TEST_PKG_NAME) ga2.init_engine_sdk(enginetype=ga2.EngineType.Unity, local_engine_port="42222") #device.start_alert_handler() time.sleep(3) device.touch(0.5, 0.75) login_test() time.sleep(1) device.touch(0.5, 0.75) logger.info("iOSDevice_LoginTest end") #device.iproxy.removeAllForwards()
''' a sample to assert element exists ''' def wait_fail_test(): assert(ga2.wait_element(ga2.By.NAME_IN_ENGINE, "badboy",timeout=6)) ''' a sample to touch engine element ''' def touch_test(): ga2.touch_element(ga2.By.NAME_IN_ENGINE, "/Canvas/Panel/FindElements") ''' a sample to get the screenshot ''' def screenshot_test(): image = device.screenshot() cv2.imwrite("test.jpg", image) device = ga2.init_device(ga2.DeviceType.DEVICE_IOS, TestInfo.udid) # get the instance of device ga2.launch_app(TestInfo.PACKAGE)#if you are going to test a specific scene, just comment out this line. ga2.init_engine_sdk(enginetype=EngineType) wait_test() touch_test() random_travel() screenshot_test() wait_fail_test() # device.iproxy.removeAllForwards()
import ga2 from ga2.device.device import Device from ga2_contrib.sample_engine_extention.myEngine import * udid = "8b281ff151d795bfc81212e45068dea12b91b706" if __name__ == "__main__": device = ga2.init_device(ga2.DeviceType.DEVICE_IOS, udid) # get the instance of device ga2.launch_app("com.tencent.wetest.demo.ngui") # if you are going to test a specific scene, just comment out this line. ga2.init_engine_sdk(enginetype=ga2.EngineType.MY_ENGINE, local_engine_port="42222") ga2.touch_element(ga2.By.NAME_IN_ENGINE,"/Canvas/Panel/FindElements")