首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Appium无法滚动到Accessibility_ID

Appium无法滚动到Accessibility_ID
EN

Stack Overflow用户
提问于 2020-07-23 06:13:16
回答 2查看 406关注 0票数 0

http://appium.io/docs/en/commands/interactions/touch/scroll/

我想滚动到一个元素。我一直在犯错误。修复可能很简单,但我完全迷路了。

代码语言:javascript
复制
Error: "undefined method `scroll' for #<Appium::TouchAction:0x000055d15d31c980> (NoMethodError)"

我的节目是:

2.5.1p57

  • touch_action (1.3.3)

  • appium_lib

  • (3.7.0)

下面是我的密码。

代码语言:javascript
复制
require 'appium_lib'
require 'touch_action'
#require 'selenium-webdriver'

server_url = "http://127.0.0.1:4723/wd/hub"

opts = {
         caps: {
           platformName: :Android,
           platformVersion: 9,
           deviceName: :'Android Emulator',
           app: 'TheApp-v1.9.0.apk',
           newCommandTimeout: 600,
           automationName: :Appium,
           javascript_enabled: true
         }
  }


driver = Appium::Driver.new(opts, true)
driver.start_driver
ta = Appium::TouchAction.new.driver

sleep 5

scroll1 = ta.scroll_to(:accessibility_id, "Verify Phone Number")
scroll1.perform

sleep 2

print "Completed Successfully!"

driver.driver_quit
EN

回答 2

Stack Overflow用户

发布于 2020-07-23 17:52:09

在Ruby中,scroll_to历来是一片狼藉的。我建议编写您自己的逻辑,类似于以下内容:

代码语言:javascript
复制
ta = Appium::TouchAction.new.driver
swipeUp = ta.swipe(startX, startY, endX, endY, duration)
clicked = false

(0...times).each do
    swipeUp.perform
    unless verifyPhoneNumber.isDisplayed
        verifyPhoneNumber.click
        clicked = true
    end
    break if clicked == true
end

我的Ruby和Appium有点生疏;如果上面有任何错误,很抱歉,但是您应该知道要点。

对于可重用性,我可能会创建一个具有此逻辑的函数,该函数将返回要滚动到的元素。

票数 0
EN

Stack Overflow用户

发布于 2022-03-27 22:03:16

下面为我工作(解决方案是为Ruby+Appium+Android)

要求'rubygems‘要求'appium_lib’

代码语言:javascript
复制
desired_caps = {
      "appium:deviceName": "055542505S003131",
      "platformName": "android",
      "appium:appPackage": "app.endometriose.android",
      "appium:noReset": true,
      "automationName": "UiAutomator2",
      "appium:appActivity": "host.exp.exponent.MainActivity",
      "app": "/users/user/myApp.apk"
  }

appium_driver = Appium::Driver.new({'caps' => desired_caps, }, true)
 
# Scroll

        appium_driver.scroll_to("Button")
**Note:** scroll_to methods takes visible text of the element and scroll to it.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63047980

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档