from appium import webdriver
# 启动参数
desired_caps = {}
desired_caps['platformName'] = 'Android' # 系统
desired_caps['platformVersion'] = '7.1.2' # 系统版本
desired_caps['deviceName'] = '127.0.0.1:62001' # 模拟器的IP,如果是真机则是写真机的名字
desired_caps['appPackage'] = 'io.manong.developerdaily' # APP包名
desired_caps['appActivity'] = 'io.toutiao.android.ui.activity.LaunchActivity' # 启动名
# 声明手机驱动
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# 获取屏幕宽度和高度
def getSize():
width_x = driver.get_window_size()['width']
height_y = driver.get_window_size()['height']
return (width_x, height_y)
# 向左滑动
def swipeLeft():
left = getSize()
x1 = int(left[0] * 0.9)
y1 = int(left[1] * 0.5)
x2 = int(left[0] * 0.1)
driver.swipe(x1, y1, x2, y1)
# 向左滑动跳过引导页
x = 0
while x < 4:
swipeLeft()
x += 1
enterApp = driver.find_element_by_id("io.manong.developerdaily:id/btn_primary")
enterApp.click()
Python + Appium解决启动应用后的滑动引导页
最新推荐文章于 2023-03-07 19:58:30 发布