from uiautomator2 import Device def click_search_icon(d: Device): (d .xpath('//*[@resource-id="com.ss.android.ugc.aweme:id/ybv"]/android.widget.Button[1]/android.widget.FrameLayout[1]') .click()) def input_search_text(d: Device, text: str): (d .xpath('//*[@resource-id="com.ss.android.ugc.aweme:id/et_search_kw"]').set_text(text))