Appium滚动直到找不到元素

时间:2020-06-12 04:19:05

标签: android automated-tests appium

我找到了滚动直到找到元素的代码,

WebElement el = driver.findElementByAndroidUIAutomator
("new UiScrollable(new UiSelector().scrollable(true).instance(0))
.scrollIntoView(new UiSelector().textContains(\""+text+"\").instance(0))");
el.click();

如何修改代码以滚动直到元素不包含特定文本?

1 个答案:

答案 0 :(得分:0)

尝试类似的方法,它在python中但可以自我解释-

def scroll_element_into_view_android(list_element, search_text):

    element = driver.find_element_by_android_uiautomator(
        'new UiScrollable(new UiSelector().resourceId(\"' + list_element + '\")).scrollIntoView(new UiSelector().textContains(\"' + search_text + '\").instance(0));')
    return element