[英]How to scroll list once in android application using Appium and Python
I want to scroll into a list in an Android app using Python and the following code is working for me:我想使用 Python 滚动到 Android 应用程序中的列表,以下代码对我有用:
self.driver.find_element_by_android_uiautomator('new UiScrollable(newUiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("India").instance(0));')
But this scrolls the list until it doesn't India, but I only want to scroll once.但这会滚动列表,直到它不是印度,但我只想滚动一次。
I tried this one also:我也试过这个:
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)
This also scrolling the list but it is doing a long scrolling, but i want to go to each and every element in the list.这也滚动列表,但它正在滚动很长一段时间,但我想转到列表中的每个元素。
Can anyone tell me how to scroll the list once?谁能告诉我如何滚动列表一次?
I tried below mentioned code and worked perfectly for me which i wants.我尝试了下面提到的代码,并且非常适合我,这是我想要的。 i just used the touch action like press and release, as i want to scroll once, so remove release() part from it and then it worked perfectly for me :)
我只是使用了像按下和释放这样的触摸动作,因为我想滚动一次,所以从中删除 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()
Who else want the same, he/she can use the same fundamentals.还有谁想要相同的,他/她可以使用相同的基本原理。
I have just scrolled, and it awesome.我刚刚滚动,它太棒了。 You just need to swipe from bottom to up, when test is running.
当测试运行时,您只需要从下往上滑动即可。 Try it, it works 100%.
试试看,它 100% 有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.