简体   繁体   English

如何使用 Appium 和 Python 在 android 应用程序中滚动列表一次

[英]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.

相关问题 在使用 appium 的 Android 移动应用程序上,如何获取我们需要滚动的 web 元素列表? - On Android Mobile application using appium , how to fetch the list of web-Elements for which we need to scroll? 如何使用Appium与Robot Framework滚动以在Android设备上测试应用程序 - How to scroll with Robot Framework using Appium to test an application at Android device 无法使用python在带有appium的android中滚动 - Unable to scroll in android with appium using python 如何通过 Python 客户端使用 Appium 滚动 Android 应用程序 - How to scroll Android app with Appium by Python Client 如何使用Java Appium Client在Android中滚动? - How to scroll in android using java appium client? 如何使用appium在android中滚动listview? - how to scroll a listview in android using appium? 如何使用appium在android应用程序中滚动表单 - How to scroll form in android app using appium 无法使用python在Android的Appium 1.14.16中执行滚动 - Not able to perform scroll in appium 1.14.16 on Android using python 如何使用appium和python控制android设备? - How to control android device using appium and python? 如何使用appium和java向下滚动点击Android中的元素? - How to scroll down to click the element in Android using appium and java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM