# -*- coding: UTF-8 -*-
from appium import webdriver
import time
desired_caps = dict()
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0'
desired_caps['deviceName'] = '192.168.135.104:5555'
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
#找到搜索点击
time.sleep(5)
driver.find_element_by_id("com.android.settings:id/search").click()
print('---已点击搜索按钮并点击---')
#找到搜索,在搜索文本框输入hello
input_buttons = driver.find_element_by_id("android:id/search_src_text").send_keys("hello")
time.sleep(5)
print('---已点输入hello---')
#点击返回按钮
driver.find_element_by_xpath("//*[@content-desc='收起']").click()
time.sleep(5)
print('---已点击返回按钮---')
driver.quit()