appium元素定位
元素定位方法
1)id定位: resource-id属性值
2)class定位: class属性值
3)xpath定位: xpath表达式
driver.find_elements_by_xpath("//*[contains(@text,'设')]")
driver.find_element(By.XPATH,'//android.widget.EditText').send_keys('你好')
4)content定位:content-desc属性值
driver.find_element_by_accessibility_id(content-desc属性值)
定位一组元素elements
返回的是一个例表,可以通过下标来调用列表中的元素,
如果定位不到元素,不会报错,返回空列表
元素等待跟web一样
隐式等待driver.implicitly_wait(timeout)
显示等待WebDriverWait(driver, 10).until(lambda x:x.find_element(By.ID, 'value'))
强制等待time.sleep(3)
以下知识点实例汇总:
import time
from appium import webdriver
# 启动参数
from selenium.webdriver.common.by import By
############cap参数#######################################
cap = {