Appium + python -小程序实例

标签:res   dev   red   idt   int   bdr   idp   proc   print   

from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
from time import sleep

desired_caps = {
‘platformName‘: ‘Android‘,
‘platformVersion‘: ‘9‘,
‘deviceName‘: ‘4871660c‘,
‘appPackage‘: ‘com.tencent.mm‘,
‘appActivity‘: ‘.ui.LauncherUI‘,
‘automationName‘: ‘Appium‘,
# ‘unicodeKeyboard‘: True,
# ‘resetKeyboard‘: True,
‘noReset‘: True,
‘chromeOptions‘: {‘androidProcess‘: ‘com.tencent.mm:appbrand0‘}
}

driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘, desired_caps)

# def swipeDown(driver,t=100,n=1):
# """向下滑动屏幕"""
# size = driver.get_window_size()
# print(size)
# x1 = size[‘width‘]*0.5
# y1 = size[‘height‘]*0.25
# y2 = size[‘height‘]*0.75
# for i in range(n):
# driver.swipe(x1,y1,x1,y2,t)
#
# swipeDown(driver)
# sleep(2)

sleep(3)
#打印屏幕宽和高
print(driver.get_window_size())
#获取屏幕的宽
x = driver.get_window_size()[‘width‘]
#获取屏幕的高
y = driver.get_window_size()[‘height‘]

#向下滑动
driver.swipe(1 / 2 * x, 1 / 7 * y, 1 / 2 * x, 6 / 7 * y, 200)
sleep(3)

#获取当前的会话
print(driver.contexts)

#点开小程序
driver.find_element_by_id("com.tencent.mm:id/jb")[1].click()
sleep(2)



Appium + python -小程序实例

标签:res   dev   red   idt   int   bdr   idp   proc   print   

原文地址:https://www.cnblogs.com/Teachertao/p/10990940.html

微擎相关资料:
未经允许不得转载:微擎二次开发视频 » Appium + python -小程序实例

为您推荐

评论列表

还木有评论 ,赶紧来一个!嘻嘻,:)

发表评论

访客的头像

Top