def test_search(self):
'''使用 xpath 定位'''
logging.info("搜索用例")
element = self.driver.find_element(MobileBy.XPATH,"//*[@resource-id='com.xueqiu.android:id/tv_search']")
search_enabled = element.is_enabled()
logging.info(f"搜索框的文本:{element.text},搜索框的坐标:{element.location},搜索框的size:{element.size}")
if search_enabled == True:
logging.info("点击搜索框")
element.click()
logging.info(f"输入搜索内容:alibaba")
self.driver.find_element(MobileBy.XPATH,
"//*[@resource-id='com.xueqiu.android:id/search_input_text']").\
send_keys("alibaba")
alibaba_element = self.driver.find_element(MobileBy.XPATH, "//*[@text='阿里巴巴']")
# alibaba_element.is_displayed()
displayed = alibaba_element.get_attribute("displayed")
logging.info(f"是否可见:{displayed}")
self.driver.save_screenshot("./image/search_result.png")
assert displayed == "true"