from appium import webdriver
import os
import time
import base64

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7.1'
desired_caps['devicesName'] = '192.168.50.101:5555'
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings'

#声明driver对象
driver = webdriver.Remote('http:127.0.0.1:21503/wd/hub', desired_caps)

#id、class、xpath


#点击WLAN
driver.find_element_by_xpath("//*[contains(@text, 'WLAN')]").click()


# driver.find_element_by_id("com.android.settings:id/tile_item").click()

#返回
driver.find_element_by_class_name("android.widget.ImageButton").click()


#查找一组元素
driver.find_elements_by_class_name("android.widget.TextView")

#强制等待
time.sleep(4)


#显示等待
try:
    WebDriverWait(driver,5,1).until(lambda x: x.find_element_by_xpath("//*[contains(@text, '设置')]"))
    print("找到了")
except:
    print("找不到超时了")

print(driver.find_elements_by_xpath("//*[contains(@text, '设置')]"))


#隐士等待,所有的操作页面默认等待3秒
driver.implicitly_wait(3)
print(driver.find_elements_by_xpath("//*[contains(@text, '设置')]"))


driver.close_app()
driver.quit()

相关文章:

  • 2021-11-01
  • 2021-10-28
  • 2021-08-04
  • 2021-07-30
  • 2022-03-01
  • 2021-12-08
  • 2022-02-23
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2021-09-15
  • 2021-12-05
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案