【问题标题】:How to scroll in appium (ios, real device) python a half screen如何在appium(ios,真机)python中滚动半屏
【发布时间】:2017-06-18 00:00:43
【问题描述】:

我有一个问题,我必须向上滚动日历,其中每一天都有自己的元素(可能会添加或删除)并找到上一个日期的元素。

我只需要 - 从这里滚动到某个特定元素(假设它没有重复)。

我试过了-

self.driver.execute_script("mobile: scroll", {"direction": "up"})

它可以工作,但有时它会滚动并且元素会再次变得不可见

理想的方法是有一些从这里滚动到某个元素的方法 或者不是滚动整个屏幕,而是只滚动一半。

我尝试了以下方法:

self.driver.execute_script("mobile: scroll", {"direction": "up", 'element': el})

self.driver.execute_script("mobile: scrollTo", {"direction": "up", 'element': el.id})

但它不起作用。

  • 硒 (3.0.1)
  • Appium (1.6.3)
  • Python 2.7

【问题讨论】:

    标签: python ios appium


    【解决方案1】:

    我找到了解决办法。也许它会对某人有所帮助: 例如,就我而言,它将是(可滚动只是屏幕的左侧部分)

    【讨论】:

      【解决方案2】:

      使用它,它有效。之后就可以根据您的需要睡觉了。

      action = TouchAction(self.driver)
      action.long_press(elementToTap).move_to(elementToDrag).release().perform()
      

      【讨论】:

        【解决方案3】:
        1. 您应该使用不带 To 的滚动
        2. 您需要在同一字典中的“元素”旁边添加“toVisible”
        3. 元素 ID 不是定位器 ID,而是会话中的 ID。可以使用getId()方法获取

        self.driver.execute_script("mobile: scroll", {"direction": "up", 'element': el.id, 'toVisible' : 'any non empty text'})

        这应该适合你

        【讨论】:

          猜你喜欢
          • 2017-02-04
          • 2018-08-11
          • 2018-01-01
          • 2016-09-23
          • 2018-08-08
          • 2015-05-06
          • 2015-04-01
          • 2014-12-26
          • 2020-04-22
          相关资源
          最近更新 更多