37 lines
892 B
Python
37 lines
892 B
Python
import logging
|
|
|
|
from uiautomator2 import Device
|
|
|
|
|
|
def click_search_btn(d: Device):
|
|
selector = d.xpath('//*[@resource-id="com.tencent.mm:id/h5n"]')
|
|
if selector.exists:
|
|
selector.click()
|
|
else:
|
|
logging.warning("未找到组件")
|
|
|
|
|
|
def input_search_text(d: Device, text: str):
|
|
clear_btn = d.xpath('//*[@resource-id="com.tencent.mm:id/nhn"]')
|
|
if clear_btn.exists:
|
|
clear_btn.click()
|
|
|
|
selector = d.xpath('//*[@resource-id="com.tencent.mm:id/mdd"]')
|
|
|
|
if selector.exists:
|
|
selector.set_text(text)
|
|
else:
|
|
logging.warning("未找到组件")
|
|
|
|
|
|
def click_search_result(d: Device):
|
|
selector = d.xpath('//*[@resource-id="com.tencent.mm:id/kbo"]')
|
|
selector.wait(timeout=3)
|
|
elements = selector.all()
|
|
print(elements)
|
|
|
|
if len(elements) > 0:
|
|
elements[0].click()
|
|
else:
|
|
logging.warning("未找到组件")
|