http://appium.io/docs/en/commands/interactions/touch/scroll/
我想滚动到一个元素。我一直在犯错误。修复可能很简单,但我完全迷路了。
Error: "undefined method `scroll' for #<Appium::TouchAction:0x000055d15d31c980> (NoMethodError)"我的节目是:
2.5.1p57
下面是我的密码。
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发布于 2020-07-23 17:52:09
在Ruby中,scroll_to历来是一片狼藉的。我建议编写您自己的逻辑,类似于以下内容:
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有点生疏;如果上面有任何错误,很抱歉,但是您应该知道要点。
对于可重用性,我可能会创建一个具有此逻辑的函数,该函数将返回要滚动到的元素。
发布于 2022-03-27 22:03:16
下面为我工作(解决方案是为Ruby+Appium+Android)
要求'rubygems‘要求'appium_lib’
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.https://stackoverflow.com/questions/63047980
复制相似问题