id:
driver.find_element_by_id('id名')
name:
driver.find_element_by_name('name名')
class
driver.find_element_by_class_name('class名')
xpath
driver.find_element_by_xpath("//*[@name='chunli']")
xpath层级定位:
driver.find_element_by_xpath("//form[@id='form']/span/input")
driver.find_element_by_css_seletor('.spn_t').click()
driver.find_element_by_css_seletor('#su')
appium元素定位:
id定位:
driver.find_element_By_id('resouceId')
name定位:
driver.find_element_by_name('text内容')
class定位:
driver.findZ_element_by_class_name(‘android.widget.TextView’)
相对定位
elements=driver.find_element_by_id("android_register_parent")
element.find_element_by_class_name('android.widget.ImageView').click()
xpath定位:
driver.find_element_by_xpath(//android.widget_Button").click()
driver.find_element_by_xpath('//*[@class="android.widget.Button"]')
driver.find_element_by_xpath('//*[@class="android.widget.Button" and @text="3"]').click()
driver.find_element_by_xpath(//android.widget.editText[@text="请输入用户名"])
list定位
images=driver.find_elements_by_id(//android.widget.ImageView)
iamge[2].click()
uiautomattor定位
id定位
driver.find_element_by_android_uiautomator('new uiselector().resourcezId("i")')
class定位
driver.find_element_by_android_uiautomator('new uiselector().text("hsdkshdk")')
xpath定位
driver.find_element_by_android_uiautomator('new Uiselector().className('android.widget.EditView')')
隐式等待
webdriver.implicitly_wait(2)
显示等待
webdriverWait(driver,timeout,poll_frequency,ignored_exception)
timeout:超时
poll_frequency:休眠时间间隔时间
ignored_exception:超时后的异常信息