0

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.

What is the simplest way to scroll with appium in android using python? Any full test examples?

John P.
  • 4,358
  • 4
  • 35
  • 47
minar09
  • 453
  • 6
  • 17

3 Answers3

2
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.

Since to scroll we hold screen at bottom & move up.

value of x depends on how much you wish to scroll in one shot. Example: To scroll to the bottom, try 300. To scroll little x can be 1200

Jaap
  • 81,064
  • 34
  • 182
  • 193
akvenk
  • 466
  • 3
  • 8
0

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.

minar09
  • 453
  • 6
  • 17
0

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. Once, I had an issue with self.driver.scroll(), so this can also be a workaround.

Remy
  • 31
  • 6