标签:
1、通过resourceID获取 driver.find_element_by_id("com.android.contacts:id/menu_add_contact").click()
2、通过name:findElementByName( "name")3、findElementByClassName(”classname“)4、findElementByAccessibilityId()在安卓上等同于contentDescription
#coding=utf-8
- import time
from appium import webdriver
desired_caps ={}
desired_caps[‘platformName‘]=‘Android‘
desired_caps[‘platformVersion‘]=‘4.4.4‘
desired_caps[‘deviceName‘]=‘Android Emulator‘
desired_caps[‘appPackage‘]=‘com.XX.activity‘
desired_caps[‘appActivity‘]=‘.XXSearchActivity‘
desired_caps[‘unicodeKeyboard‘]=True
desired_caps[‘resetKeyboard‘]=True
driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘, desired_caps)
driver.find_elements_by_name("搜索话题")
driver.find_element_by_class_name("android.widget.EditText").send_keys(u"可爱")
# driver.find_element_by_id(‘et_searchactivity_search‘).send_keys(u"可爱")
driver.find_element_by_name("搜索").click()
- time.sleep(5)//在页面暂停5秒
driver.quit()
标签:
原文地址:http://www.cnblogs.com/qingxd/p/5533748.html