Appium点击、滑动、多指触控操作

Appium点击、滑动、多指触控操作

2023年6月26日发(作者:)

Appium点击、滑动、多指触控操作通过坐标进⾏点击:()#

通过坐标进⾏点击,参数1:x,y坐标,参数2:持续时间([(778, 986)], 500)滑动屏幕:()(start_x: 960, start_y: 800, end_x: 960, end_y: 300, duration: int = 0)#

坐标起始位置,坐标终⽌位置,持续时间以下为前程贷登陆操作,涉及到滑动操作from ver import Remotefrom _action import TouchActionfrom by import MobileByfrom import WebDriverWaitfrom t import expected_conditions as ECdesired_cap = { "platformName": "Android", "platformVersion": "7.1.2", "deviceName": "HUAWEI", "appPackage": "", "appActivity": "eActivity", "noReset": True}driver = Remote(command_executor='127.0.0.1:4723/wd/hub', desired_capabilities=desired_cap)itly_wait(10)#

获取屏幕的宽、⾼win = _window_size()print(win)#

通过while循环来实现app初次启动滑屏⽴即体验while True: (start_y=960, start_x=800, end_y=960, end_x=300, duration=200) loc = (, ':id/btn_start') try: WebDriverWait(driver, 2, 0.5).until( lity_of_element_located(loc) ) except: pass else: _element(*loc).click()_element_by_android_uiautomator('new UiSelector().text("注册/登录")').click()_element_by_android_uiautomator('new UiSelector().text("请输⼊⼿机号码")').send_keys("1868xxxxxx")_element_by_android_uiautomator('new UiSelector().text("下⼀步")').click()_element_by_android_uiautomator('new UiSelector().text("请输⼊登录密码")').send_keys("python")_element_by_android_uiautomator('new UiSelector().text("确定")').click()_element_by_android_uiautomator('new UiSelector().text("马上设置")').click()_element_by_android_uiautomator('new UiSelector().text("创建⼿势密码")').click()_element_by_android_uiautomator('new UiSelector().text("确定")').click()以下为百度地图⼿指缩放地图(多指触控)操作:import timefrom ver import Remotefrom _action import MultiActionfrom _action import TouchActiondesired_cap = { "platformName": "Android", "platformVersion": "7.1.2", "deviceName": "HUAWEI", "appPackage": "ap", "appActivity": "eScreen", "noReset": True,#这个参数是⽤来控制是否清除session信息的 "adbExecTimeout": "50000"#如果是断点调试的时候,经常会出现timeout,adb connect超时}driver = Remote(command_executor='127.0.0.1:4723/wd/hub', desired_capabilities=desired_cap)itly_wait(10)win_size = _window_size()print(win_size)h = win_size['height']w = win_size['width'](10)for i in range(3): t1 = TouchAction(driver) (x=w*0.5, y=h*0.4).wait(50) _to(x=w*0.5, y=h*0.2).wait(50).release() t2 = TouchAction(driver) (x=w*0.5, y=h*0.6).wait(50) _to(x=w*0.5, y=h*0.8).wait(50).release() ma = MultiAction(driver) (t1, t2) m()以下为九宫格函数封装:def slid_pwd(driver, ele, pwd): rect = # {'height': 900, 'width': 900, 'x':90, 'y':653} left = rect['x'] top = rect['y'] y_ = rect['height']/6 x_ = rect['width']/6 dic = {1: {'x': rect['x']+x_, 'y': rect['y']+y_}, 2: {'x': rect['x']+3*x_, 'y': rect['y']+y_}, 3: {'x': rect['x']+5*x_, 'y': rect['y']+y_}, 4: {'x': rect['x']+x_, 'y': rect['y']+3*y_}, 5: {'x': rect['x']+3*x_, 'y': rect['y']+3*y_}, 6: {'x': rect['x']+5*x_, 'y': rect['y']+3*y_}, 7: {'x': rect['x']+x_, 'y': rect['y']+5*y_}, 8: {'x': rect['x']+3*x_, 'y': rect['y']+5*y_}, 9: {'x': rect['x']+5*x_, 'y': rect['y']+5*y_} } ta1 = TouchAction(driver) (**dic[pwd[0]]).wait(100) for i in pwd: _to(**dic[i]).wait(100) e() m()loc = (, ':id/gesturepwd_create_lockview')ele = _element(*loc)slid_pwd(driver, ele, [1, 2, 3, 5, 7, 8, 9])

发布者:admin,转转请注明出处:http://www.yc00.com/news/1687756414a39999.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信