Unable to perform scroll using TouchActions in appium (using selenium webdriver) on python client

I am trying to perform a scroll operation using the TouchActions class provided by selenium webdriver while testing on Appium(using a python client) on Android.
But I see the message : WebDriverException: Message: Not yet implemented. Please help us: http://appium.io/get-involved.html

Also when I tried to implement the swipe functionality I get the error:
AttributeError: ‘TouchActions’ object has no attribute ‘swipe’

Could anyone suggest how I could get out of this situation, where selenium webdriver doesn’t support scroll for python and doesnt contain swipe attributes?

Please provide logs.

Hi @sebv

Scroll TouchAction:
Server logs:
2015-06-18 06:30:53:320 - info: --> POST /wd/hub/session/b355d764-935f-461f-80fd-d8b00e2c61e5/touch/scroll {“sessionId”:“b355d764-935f-461f-80fd-d8b00e2c61e5”,“xoffset”:250,“yoffset”:400}
2015-06-18 06:30:53:321 - info: [debug] Responding to client that a method is not implemented
2015-06-18 06:30:53:323 - info: <-- POST /wd/hub/session/b355d764-935f-461f-80fd-d8b00e2c61e5/touch/scroll 501 2.375 ms - 158

======================================================================
ERROR: testcategory_men (main.TestHomeScreendisplay)

Traceback (most recent call last):
File “android_piQit.py”, line 57, in testcategory_men
self.touch.scroll(250,400).perform()
File “/Library/Python/2.7/site-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/common/touch_actions.py”, line 48, in perform
action()
File “/Library/Python/2.7/site-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/common/touch_actions.py”, line 125, in
‘yoffset’: int(yoffset)}))
File “/Library/Python/2.7/site-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/remote/webdriver.py”, line 195, in execute
self.error_handler.check_response(response)
File “/Library/Python/2.7/site-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/remote/errorhandler.py”, line 170, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: Not yet implemented. Please help us: http://appium.io/get-involved.html


Swipe Attribute Error:

ERROR: testcategory_men (main.TestHomeScreendisplay)

Traceback (most recent call last):
File “android_piQit.py”, line 57, in testcategory_men
self.touch.swipe(400,250,400,300).perform()
AttributeError: ‘TouchActions’ object has no attribute ‘swipe’


There were no explicit server errors for a missing swipe attribute.
Please take a look and suggest the best possible solution.
Also should this be an indication that I move onto the appium webdriver implementation( TouchAction Class) rather than Selenium (TouchActions Class) before I get far too inside my code ?

Can you please paste the complete logs, I wanna see are you using native app or hybrid. I have seen this happening to me with Touch action with hybrid and i figured out that context needs be changed to native app.

Also have have to tried to use appium functions
driver.execute_script(“mobile: scrollTo”, {“element”: .id})

@Anish_ohri

I am using a hybrid app, but my current_context is always NATIVE_APP.
I have tried mutiple approaches:

I used - driver.scroll(el1,el2) but if the element el2 wasnt in the field of view on the screen, it wouldnt move to it.

I then tried using the methid below to try using cordinates instead of elements:
smile:action=Touchaction(self.driver)
action.press(x=540,y=720).move_to(x=540,y=1000).release().perform()
But seems like if teh cordinates are also not within the range of screen display, it doesnt scroll.
Error:
action.press(x=540,y=720).move_to(x=540,y=1000).release().perform()
File “/Library/Python/2.7/site-packages/Appium_Python_Client-0.14-py2.7.egg/appium/webdriver/common/touch_action.py”, line 94, in perform
self._driver.execute(Command.TOUCH_ACTION, params)
File “/Library/Python/2.7/site-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/remote/webdriver.py”, line 195, in execute
self.error_handler.check_response(response)
File “/Library/Python/2.7/site-packages/Appium_Python_Client-0.14-py2.7.egg/appium/webdriver/errorhandler.py”, line 29, in check_response
raise wde
WebDriverException: Message: The coordinates provided to an interactions operation are invalid.

Server logs:
action.press(x=540,y=720).move_to(x=540,y=1000).release().perform()
File “/Library/Python/2.7/site-packages/Appium_Python_Client-0.14-py2.7.egg/appium/webdriver/common/touch_action.py”, line 94, in perform
self._driver.execute(Command.TOUCH_ACTION, params)
File “/Library/Python/2.7/site-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/remote/webdriver.py”, line 195, in execute
self.error_handler.check_response(response)
File “/Library/Python/2.7/site-packages/Appium_Python_Client-0.14-py2.7.egg/appium/webdriver/errorhandler.py”, line 29, in check_response
raise wde
WebDriverException: Message: The coordinates provided to an interactions operation are invalid.

Can someone please suggest a way out? I am unable to perform any swipe/scroll operation in the app.

hhmm…, Please provide the complete logs of appium next time. Also if its not working with touch.action can u switch the context to webview and try selenium click ?

Can you Also try precise tap from appium inspector to get the x y of the element.

this what i used driver.swipe(1506, 902, 1512, 600, 1) and it worked absolutely fine for me.

This is also discussed here and might help you:

i get this using driver.swipe(1506, 902, 1512, 600, 1) :

Error
Traceback (most recent call last):
File “C:\Users\QA\PycharmProjects\BantasyTestSuite\BantasyTestSuite_modified_new_design.py”, line 2668, in runTest
SelectLineupSalaryCapTest().runTest()
File “C:\Users\QA\PycharmProjects\BantasyTestSuite\BantasyTestSuite_modified_new_design.py”, line 1282, in runTest
SelectPlayers().runTest(driver, selection_indicator, run_test_on)
File “C:\Users\QA\PycharmProjects\BantasyTestSuite\Select_Players.py”, line 42, in runTest
> driver.swipe(1506, 902, 1512, 600, 1)
File “C:\Python27\lib\site-packages\appium\webdriver\webdriver.py”, line 242, in swipe
action.perform()
File “C:\Python27\lib\site-packages\appium\webdriver\common\touch_action.py”, line 94, in perform
self._driver.execute(Command.TOUCH_ACTION, params)
File “C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”, line 196, in execute
self.error_handler.check_response(response)
File “C:\Python27\lib\site-packages\appium\webdriver\errorhandler.py”, line 24, in check_response
super(MobileErrorHandler, self).check_response(response)
File “C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py”, line 103, in check_response
status = value[‘status’]
TypeError: string indices must be integers

swipe is marked as deprecated

@jblaze scroll or swipe is deprecated right? Swipe still works fine for me

Yes, it works fine for me as well. But since it has been deprecated, at some point it will no longer be available. Best to find another solution ahead of time.

For any junior tester like me who stumbles upon this page again,
Make sure that you don’t have both of these in your py:

from selenium import webdriver
from appium import webdriver

I had imported both while using selenium explicit waits to find my elements. Never do so, Its a trap.