[英]Unable to scroll in android with appium using python
I tried this piece of code: 我尝试了这段代码:
scrollObject = dict(direction="down", text="some_text", element=appium_driver_elem.id)
self.driver.execute_script("mobile: scrollTo", scrollObject)
But I am getting an error saying: 但我收到一个错误消息:
"appium_driver_elem does not have attribute like id" or sometimes nosuchelementexception.
“ appium_driver_elem不具有id之类的属性”,有时没有nosuchelementexception。
What is the simplest way to scroll with appium
in android using python
? 使用
python
在Android中滚动appium
的最简单方法是什么? Any full test examples? 有完整的测试示例吗?
self.driver.swipe(470, 1400, 470, x, 400)
self.driver.swipe(start_x, start_y, end_x, end_y, duration)
start_y
value represents bottom Y value & end_y
value represents top Y value of the screen in your app. start_y
值表示底部Y值,而end_y
值表示应用程序中屏幕的顶部Y值。
Since to scroll we hold screen at bottom & move up. 由于滚动,我们将屏幕保持在底部并向上移动。
value of x depends on how much you wish to scroll in one shot. x的值取决于您希望一次滚动多少。 Example: To scroll to the bottom, try 300. To scroll little x can be 1200
示例:要滚动到底部,请尝试300。要滚动小x可以是1200
Still haven't found an answer. 仍然没有找到答案。 So maybe you need to play a little bit rough.
因此,也许您需要玩一些粗糙的游戏。 You can use the
self.driver.scroll(self,SrcElem,DestElem)
function to swipe screen from bottom to top and check the element you seek. 您可以使用
self.driver.scroll(self,SrcElem,DestElem)
函数从下往上滑动屏幕并检查要查找的元素。
Or You can also try to do 或者您也可以尝试做
from appium.webdriver.common.touch_action import TouchAction
...
action = TouchAction(self.driver)
action.press(start_element).move_to(end_element).release().perform()
Actually, that's how scroll() function works. 实际上,这就是scroll()函数的工作方式。 Once, I had an issue with self.driver.scroll(), so this can also be a workaround.
曾经,我遇到了self.driver.scroll()问题,所以这也可以是一种解决方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.