![](/img/trans.png)
[英]On Android Mobile application using appium , how to fetch the list of web-Elements for which we need to scroll?
[英]How to scroll list once in android application using Appium and Python
我想使用 Python 滚动到 Android 应用程序中的列表,以下代码对我有用:
self.driver.find_element_by_android_uiautomator('new UiScrollable(newUiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("India").instance(0));')
但这会滚动列表,直到它不是印度,但我只想滚动一次。
我也试过这个:
el1 = self.driver.find_element_by_xpath("//*[@resource-id = 'resource-id' and @index ='1']")
el2 = self.driver.find_element_by_xpath("//*[@resource-id = 'resource-id' and @index ='0']")
self.driver.scroll(el1, el2)
这也滚动列表,但它正在滚动很长一段时间,但我想转到列表中的每个元素。
谁能告诉我如何滚动列表一次?
我尝试了下面提到的代码,并且非常适合我,这是我想要的。 我只是使用了像按下和释放这样的触摸动作,因为我想滚动一次,所以从中删除 release() 部分,然后它对我来说非常有用:)
el1 = self.driver.find_element_by_xpath("<xpath>")
el2 = self.driver.find_element_by_xpath("<xpath>")
action = TouchAction(self.driver)
action.press(el1).move_to(el2).perform()
还有谁想要相同的,他/她可以使用相同的基本原理。
我刚刚滚动,它太棒了。 当测试运行时,您只需要从下往上滑动即可。 试试看,它 100% 有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.