无法使用 touchAction 滚动浏览 iOS 应用程序

问题描述 投票:0回答:1

我正在尝试在 iOS 模拟器应用程序中滚动,使用 touchAction 如下。

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()

但是我收到以下错误。

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"
          );
      }

有人可以分享解决方案吗?

我的环境设置。

MAC iOS:红杉 15.0
XCode 版本 16.0 (16A242d)
appium 版本 2.11.4
xcuitest版本7.27.1

之前可以用,升级后就不行了。

python appium-ios
1个回答
0
投票

Touchaction 类在 appium2.0 中已弃用。 首先你可以将你的appium版本升级到appium2.0 您可以使用以下方法进行滚动活动

注意:在这里使用 Appium 检查器来查找元素的 x 和 y 坐标

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();
© www.soinside.com 2019 - 2024. All rights reserved.