Sharique Alam
Sharique Alam

Reputation: 1

Not able to scroll through iOS application using touchAction

I am trying to scroll in iOS simulator application, using touchAction as below.

def scroll_by_touch_action(self, startX, startY, endX, endY):
    actions = TouchAction(self.driver)
    actions.press(x=startX, y=startY).wait(3000).move_to(x=endX, y=endY).release().perform()

But I am getting following error.

Scenario Outline: User to verify advertisments in home feed screen -- @1.1 keywords  # member_home_feed.feature:55
    Given Handle cookies popup                                                         # steps/signup.py:62
    Given the user is logged in                                                        # steps/community.py:10
    Given user is in feed page                                                         # steps/member_home_feed.py:15
    Given Validate "7" advertisment in screen "home_feed"                              # steps/member_home_feed.py:149
      Traceback (most recent call last):
        File "/Users/shariquealam/.pyenv/versions/3.11.1/lib/python3.11/site-packages/behave/model.py", line 1329, in run
          match.run(runner.context)
        File "/Users/shariquealam/.pyenv/versions/3.11.1/lib/python3.11/site-packages/behave/matchers.py", line 98, in run
          self.func(context, *args, **kwargs)
        File "steps/member_home_feed.py", line 151, in step_impl
          context.homepage.scroll_to_ad(ad_no, screen)
        File "/Users/shariquealam/Documents/Framework/inspire_app_iOS/UI_Automation_Sharique/inspire-ios/Inspire-UIAutomation/features/pages/homepage.py", line 282, in scroll_to_ad
          self.driver.scroll_by_touch_action(startX=startX, startY=bottomY, endX=startX, endY=endY)
        File "/Users/shariquealam/Documents/Framework/inspire_app_iOS/UI_Automation_Sharique/inspire-ios/Inspire-UIAutomation/features/pages/basepage.py", line 204, in scroll_by_touch_action
          actions.press(x=startX, y=startY).wait(3000).move_to(x=endX, y=endY).release().perform()
        File "/Users/shariquealam/.pyenv/versions/3.11.1/lib/python3.11/site-packages/appium/webdriver/common/touch_action.py", line 163, in perform
          self._driver.execute(Command.TOUCH_ACTION, params)
        File "/Users/shariquealam/.pyenv/versions/3.11.1/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
          self.error_handler.check_response(response)
        File "/Users/shariquealam/.pyenv/versions/3.11.1/lib/python3.11/site-packages/appium/webdriver/errorhandler.py", line 31, in check_response
          raise wde
        File "/Users/shariquealam/.pyenv/versions/3.11.1/lib/python3.11/site-packages/appium/webdriver/errorhandler.py", line 26, in check_response
          super().check_response(response)
        File "/Users/shariquealam/.pyenv/versions/3.11.1/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
          raise exception_class(message, screen, stacktrace)
      selenium.common.exceptions.WebDriverException: Message: Unhandled endpoint: /session/3E7FAA7E-54DA-44BF-A0EF-2DA7BE74D1FB/touch/perform -- http://127.0.0.1:8100/ with parameters {
          wildcards =     (
              "session/3E7FAA7E-54DA-44BF-A0EF-2DA7BE74D1FB/touch/perform"
          );
      }

Can someone share the solution?

My env setup.

MAC iOS : Sequoia 15.0
XCode Version 16.0 (16A242d)
appium Version 2.11.4
xcuitest Version 7.27.1

Earlier, it was working Not after upgrade its not.

Upvotes: 0

Views: 29

Answers (2)

Joseph Cole-Showers
Joseph Cole-Showers

Reputation: 1

The TouchAction class in Appium was deprecated with Appium 2.0. Instead of using TouchAction for touch gestures like scrolling, swiping, or tapping, Appium now encourages the use of the W3C Actions API.

Upvotes: 0

Anindita Rath
Anindita Rath

Reputation: 11

The Touchaction class is deprecated in appium2.0 . First you can upgrade you appium version to appium2.0 and you can use below methods for the scroll activity

Note : use Appium inspector here to find x and y coordinates of the elements

public void scrollByTouchAction(AppiumDriver driver, int startX, int startY, int endX, int endY) {
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
ActionBuilder actions = new ActionBuilder(driver);
actions.pointerMove(finger, startX, startY)
       .pointerDown(finger)
       .pointerMove(finger, endX, endY)
       .pointerUp(finger)
       .perform();

Upvotes: 0

Related Questions