标签:image span app elf nbsp rem com 图片 oid
1. swipe方法语法
swipe(self, start_x, start_y, end_x, end_y, duration=None): 参数 - start_x - 开始滑动的x坐标 - start_y - 开始滑动的y坐标 - end_x - 结束点x坐标 - end_y - 结束点y坐标 - duration - 持续时间,单位毫秒
2. 手机坐标:
手机从左上角开始为0,横着的是x轴,竖着的是y轴
3. 获取屏幕的size
size = driver.get_window_size()
print (size) # {‘width‘: 1080, ‘height‘: 1920} ,返回字典类型,可使用字典的方法取width/height的值
print (size["width"]) # 获取浏览器的宽度1080
print (size["height"]) # 获取浏览器的高度1920
4. app上、下、左、右滑动方法
# coding:utf-8 from appium import webdriver from time import sleep desired_caps = { ‘platformName‘: ‘Android‘, ‘deviceName‘: ‘30d4e606‘, ‘platformVersion‘: ‘4.4.2‘, # apk包名 ‘appPackage‘: ‘com.taobao.taobao‘, # apk的launcherActivity ‘appActivity‘: ‘com.taobao.tao.welcome.Welcome‘ } driver = webdriver.Remote(‘http://127.0.0.1:4723/wd/hub‘, desired_caps) def swipeUp(driver, t=500, n=1): ‘‘‘向上滑动屏幕‘‘‘ l = driver.get_window_size() x1 = l[‘width‘] * 0.5 # x坐标 y1 = l[‘height‘] * 0.75 # 起始y坐标 y2 = l[‘height‘] * 0.25 # 终点y坐标 for i in range(n): driver.swipe(x1, y1, x1, y2, t) def swipeDown(driver, t=500, n=1): ‘‘‘向下滑动屏幕‘‘‘ l = driver.get_window_size() x1 = l[‘width‘] * 0.5 # x坐标 y1 = l[‘height‘] * 0.25 # 起始y坐标 y2 = l[‘height‘] * 0.75 # 终点y坐标 for i in range(n): driver.swipe(x1, y1, x1, y2,t) def swipLeft(driver, t=500, n=1): ‘‘‘向左滑动屏幕‘‘‘ l = driver.get_window_size() x1 = l[‘width‘] * 0.75 y1 = l[‘height‘] * 0.5 x2 = l[‘width‘] * 0.25 for i in range(n): driver.swipe(x1, y1, x2, y1, t) def swipRight(driver, t=500, n=1): ‘‘‘向右滑动屏幕‘‘‘ l = driver.get_window_size() x1 = l[‘width‘] * 0.25 y1 = l[‘height‘] * 0.5 x2 = l[‘width‘] * 0.75 for i in range(n): driver.swipe(x1, y1, x2, y1, t) if __name__ == "__main__": print(driver.get_window_size()) sleep(5) swipLeft(driver, n=2) sleep(2) swipRight(driver, n=2)
标签:image span app elf nbsp rem com 图片 oid
原文地址:https://www.cnblogs.com/zpf1092841490/p/11663159.html