通过群组名称:
loc_text ='new UiSelector().text("至亲一家人")'
driver.find_element_by_android_uiautomator(loc_text).click()
通过位置坐标点击:driver.tap([(643, 2090), (707, 2134)])#点击看一看的坐标
from appium import webdriver
from time import sleep
desired_caps = {
'platformName': 'Android',
'deviceName': '127.0.0.1:62001',
'platformVersion': '4.4.2',
'appPackage': 'com.baidu.yuedu',
'appActivity': 'com.baidu.yuedu.splash.SplashActivity',
'noReset': 'true',
'resetKeyboard': 'true',
'unicodeKeyboard': 'true'
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
# 等主页面activity出现
driver.wait_activity(".base.ui.MainActivity", 10)
# 1.text
loc_text = 'new UiSelector().text("图书")'
driver.find_element_by_android_uiautomator(loc_text).click()
# # 2.textContains
# loc_textContains = 'new UiSelector().textContains("图")'
# driver.find_element_by_android_uiautomator(loc_textContains).click()
# # 3.textStartsWith
# loc_textStart = 'new UiSelector().textStartsWith("图")'
# driver.find_element_by_android_uiautomator(loc_textStart).click()
sleep(2)
# resourceId定位'小说'
loc_id = 'new UiSelector().resourceId("com.baidu.yuedu:id/webbooktitle")'
driver.find_element_by_android_uiautomator(loc_id).click()
sleep(2)
# className复数定位
loc_class = 'new UiSelector().className("android.widget.TextView")'
driver.find_elements_by_android_uiautomator(loc_class)[2].click()
from appiumimport webdriver
import time
desired_caps = {}
desired_caps = {
'platformName':'Android',
'deviceName':'7a46929',
'appPackage':'com.tencent.mm',
'appActivity':'com.tencent.mm.ui.LauncherUI',
'noReset':'True',
'chromeOptions': {'androidProcess':'com.tencent.mm:tools'}
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
aa = driver.contexts
print(aa)
time.sleep(10)
print('马上点击发现')
#loc_text = 'new UiSelector().text("至亲一家人")'
#driver.find_element_by_android_uiautomator(loc_text).click()
driver.tap([(643, 2090), (707, 2134)])#点击看一看的坐标
print('点击发现')
time.sleep(5)
print(driver.contexts)
print('马上点击看一看')
#driver.tap([(151,761), (289,823)])
kanyikan ='new UiSelector().text("看一看")'
driver.find_element_by_android_uiautomator(kanyikan).click()
print('点击看一看')
time.sleep(3)
网友评论