appium使用find_element_by_xxx方式成功2
# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python
from appiumimport webdriver
from appium.webdriver.common.touch_actionimport TouchAction
import time
caps = {}
caps["app"] ="D:\\MyApplication\\app\\release\\app-release.apk"
caps["platformName"] ="Android"
# caps["deviceName"] = "UYT0217A21002556"
caps["deviceName"] ="2948d102"
caps["appPackage"] ="com.example.administrator.myapplication"
caps["appActivity"] =".SettingsActivity"
driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
#下方代码有错误,原因未知,后续再找
# general = driver.find_element_by_name("General")
general = driver.find_element_by_android_uiautomator('new UiSelector().text("General")');
general.click()
time.sleep(60)
#
# TouchAction(driver).tap(x=234, y=318).perform()
# time.sleep(1)
# TouchAction(driver).tap(x=967, y=377).perform()
# time.sleep(1)
# TouchAction(driver).tap(x=100, y=172).perform()
# time.sleep(1)
# TouchAction(driver).tap(x=264, y=469).perform()
# time.sleep(1)
# TouchAction(driver).tap(x=959, y=314).perform()
# time.sleep(1)
# TouchAction(driver).tap(x=967, y=707).perform()
# time.sleep(1)
# TouchAction(driver).tap(x=946, y=318).perform()
# time.sleep(1)
# TouchAction(driver).tap(x=75, y=180).perform()
# time.sleep(5)
driver.quit()