如何在点击元素之前,先滚动到该元素呢?
你可以查找一次 没找到就滚动一次再找 重复循环直到找到或者超过时间/滚动次数
def scroll_ele_and_click(self, text_content):
'''
滚动到某个元素,
:param text_content: 元素的文本内容
:return:
'''
self._driver.find_element(MobileBy.ANDROID_UIAUTOMATOR,
f'new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("{text_content}").instance(0));'
).click()
我是这样写的