【问题标题】:Not able to perform scroll in appium 1.14.16 on Android using python无法使用 python 在 Android 上的 appium 1.14.16 中执行滚动
【发布时间】:2016-12-13 18:09:18
【问题描述】:

这是我的代码

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4.2'
desired_caps['deviceName'] = 'Gaurav'
# Returns abs path relative to this file and not cwd
#desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__), 'ApiDemos-debug.apk'))
desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__), 'ragga.apk'))
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.implicitly_wait(100)
driver.find_element_by_id('com.raaga.android:id/skip_text').click()
driver.find_element_by_id('com.raaga.android:id/landing_skip_to_raaga').click()
driver.find_element_by_name('Hindi').click()
e1 = driver.find_element_by_android_uiautomator('new UiSelector().text("Most Popular")')
e2 = driver.find_element_by_android_uiautomator('new UiSelector().text("Remix")')
print e1,e2
driver.scroll(e1, e2)

我想执行滚动,但在屏幕上它没有执行任何操作。 这是安卓设备的截图

以下是 Appium 服务器日志:

info: [debug] [BOOTSTRAP] [debug] 注册的崩溃观察者。 信息:[调试] [BOOTSTRAP] [调试] 客户端已连接 信息:[debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"wake","params":{}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:wake 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0} 信息:[调试] 执行 cmd:C:\sdk\platform-tools\adb.exe -s 4d001f6ab48f90e9 shell "dumpsys window" 信息:[调试] 屏幕已解锁,继续。 信息:[调试] 将命令推送到 appium 工作队列:[“getDataDir”,{}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"getDataDir","params":{}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令操作:getDataDir 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":"/data/local/tmp","status":0} 信息:[调试] dataDir 设置为:/data/local/tmp 信息:[调试]将命令推送到 appium 工作队列:[“compressedLayoutHierarchy”,{“compressLayout”:false}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令操作:compressedLayoutHierarchy 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":false,"status":0} 信息:[调试] 获取设备 API 级别 信息:[调试] 执行 cmd:C:\sdk\platform-tools\adb.exe -s 4d001f6ab48f90e9 shell "getprop ro.build.version.sdk" 信息:[调试] 设备处于 API 级别 19 信息:[调试] 执行 cmd:C:\sdk\platform-tools\adb.exe -s 4d001f6ab48f90e9 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.raaga.android/com.raaga.android.SplashScreen" 信息:[调试]等待 pkg“com.raaga.android”和活动“com.raaga.android.SplashScreen”被关注 信息:[调试] 获得重点包和活动 信息:[调试] 执行 cmd:C:\sdk\platform-tools\adb.exe -s 4d001f6ab48f90e9 shell "dumpsys window windows" 信息:[调试] 执行 cmd:C:\sdk\platform-tools\adb.exe -s 4d001f6ab48f90e9 shell "getprop ro.build.version.release" 信息:[调试] 设备版本为 4.4.2 信息:[调试] 设备启动!准备好命令 info: [debug] 将命令超时设置为默认值 60 秒 信息:[调试] Appium 会话以 sessionId 2c7f4312-23aa-4b5d-8b65-ae1f012797d0 开始 信息: GET /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0 {} 信息:[调试]成功响应客户端:{"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.2"," webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion" :"4.4.2","deviceName":"Gaurav","app":"C:\Users\Gaurav.Kumar-admin\PycharmProjects\NewTest\Learning\thirtyday\apps\ragga.apk","platformName": "Android"},"deviceName":"4d001f6ab48f90e9","app":"C:\Users\Gaurav.Kumar-admin\PycharmProjects\NewTest\Learning\thirtyday\apps\ragga.apk","platformName":"Android "},"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0"} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/timeouts/implicit_wait {"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0","ms":100000} 信息:[调试] 将 Android 隐式等待设置为 100000 毫秒 信息:[调试]成功响应客户端:{“status”:0,“value”:null,“sessionId”:“2c7f4312-23aa-4b5d-8b65-ae1f012797d0”} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/元素 {"using":"id","sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0","价值":"com.raaga.android:id/skip_text"} 信息:[调试] 等待 100000 毫秒的条件 信息:[调试] 将命令推送到 appium 工作队列:["find",{"strategy":"id","selector":"com.raaga.android:id/skip_text","context":"","多个“:假}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"id","selector": "com.raaga.android:id/skip_text","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/skip_text:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/skip_text] 信息:[debug] [BOOTSTRAP] [debug] 未能找到元素。清除辅助功能缓存并重试。 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/skip_text:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/skip_text] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":"No element found","status":7} 信息:[调试] 到目前为止等待了 911 毫秒 信息:[调试] 将命令推送到 appium 工作队列:["find",{"strategy":"id","selector":"com.raaga.android:id/skip_text","context":"","多个“:假}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"id","selector": "com.raaga.android:id/skip_text","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/skip_text:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/skip_text] 信息:[debug] [BOOTSTRAP] [debug] 未能找到元素。清除辅助功能缓存并重试。 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/skip_text:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/skip_text] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":"No element found","status":7} 信息:[调试] 到目前为止等待了 1510 毫秒 信息:[调试] 将命令推送到 appium 工作队列:["find",{"strategy":"id","selector":"com.raaga.android:id/skip_text","context":"","多个“:假}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"id","selector": "com.raaga.android:id/skip_text","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/skip_text:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/skip_text] 信息:[debug] [BOOTSTRAP] [debug] 未能找到元素。清除辅助功能缓存并重试。 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/skip_text:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/skip_text] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":"No element found","status":7} 信息:[调试] 到目前为止等待了 2023 毫秒 信息:[调试] 将命令推送到 appium 工作队列:["find",{"strategy":"id","selector":"com.raaga.android:id/skip_text","context":"","多个“:假}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"id","selector": "com.raaga.android:id/skip_text","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/skip_text:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/skip_text] 信息:[debug] [BOOTSTRAP] [debug] 未能找到元素。清除辅助功能缓存并重试。 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/skip_text:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/skip_text] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":"No element found","status":7} 信息:[调试] 到目前为止等待了 2612 毫秒 信息:[调试] 将命令推送到 appium 工作队列:["find",{"strategy":"id","selector":"com.raaga.android:id/skip_text","context":"","多个“:假}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"id","selector": "com.raaga.android:id/skip_text","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/skip_text:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/skip_text] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"ELEMENT":"1"},"status":0} 信息:[调试]成功响应客户端:{"status":0,"value":{"ELEMENT":"1"},"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0"} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/element/1/点击 {"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0","id":" 1"} 信息:[debug] 将命令推送到 appium 工作队列:["element:click",{"elementId":"1"}] 信息:[调试] [BOOTSTRAP] [调试] 从客户端获取数据:{"cmd":"action","action":"element:click","params":{"elementId":"1"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:点击 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0} 信息:[调试]成功响应客户端:{“status”:0,“value”:true,“sessionId”:“2c7f4312-23aa-4b5d-8b65-ae1f012797d0”} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/元素 {"using":"id","sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0","价值":"com.raaga.android:id/landing_skip_to_raaga"} 信息:[调试] 等待 100000 毫秒的条件 信息:[调试] 将命令推送到 appium 工作队列:["find",{"strategy":"id","selector":"com.raaga.android:id/landing_skip_to_raaga","context":"","多个“:假}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"id","selector": "com.raaga.android:id/landing_skip_to_raaga","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find 信息:[调试] [BOOTSTRAP] [调试] 使用带有 contextId 的 ID 查找 com.raaga.android:id/landing_skip_to_raaga:multiple:false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[INSTANCE=0, RESOURCE_ID=com.raaga.android:id/landing_skip_to_raaga] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"ELEMENT":"2"},"status":0} 信息:[调试]成功响应客户端:{"status":0,"value":{"ELEMENT":"2"},"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0"} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/element/2/点击 {"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0","id":" 2"} 信息:[debug] 将命令推送到 appium 工作队列:["element:click",{"elementId":"2"}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:click","params":{"elementId":"2"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:点击 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0} 信息:[调试]成功响应客户端:{“status”:0,“value”:true,“sessionId”:“2c7f4312-23aa-4b5d-8b65-ae1f012797d0”} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/元素 {"using":"name","sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0","价值":"印地语"} 警告:[已弃用]名称定位器策略已被弃用并将被删除。请改用可访问性 id 定位器策略。 信息:[调试] 等待 100000 毫秒的条件 信息:[调试] 将命令推送到 appium 工作队列:["find",{"strategy":"name","selector":"Hindi","context":"","multiple":false}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"name","selector": "印地语","上下文":"","多个":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find info: [debug] [BOOTSTRAP] [debug] 使用 NAME 和 contextId 查找印地语:multiple: false 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[DESCRIPTION=Hindi, INSTANCE=0] 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[TEXT=Hindi, INSTANCE=0] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"ELEMENT":"3"},"status":0} 信息:[调试]成功响应客户端:{"status":0,"value":{"ELEMENT":"3"},"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0"} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/element/3/点击 {"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0","id":" 3"} 信息:[debug] 将命令推送到 appium 工作队列:["element:click",{"elementId":"3"}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:click","params":{"elementId":"3"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:点击 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0} 信息:[调试]成功响应客户端:{“status”:0,“value”:true,“sessionId”:“2c7f4312-23aa-4b5d-8b65-ae1f012797d0”} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/element {"using":"-android uiautomator","sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0" ,"value":"new UiSelector().text(\"最受欢迎\")"} 信息:[调试] 等待 100000 毫秒的条件 信息:[调试] 将命令推送到 appium 工作队列:["find",{"strategy":"-android uiautomator","selector":"new UiSelector().text(\"Most Popular\")","上下文":"","多个":false}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector ":"new UiSelector().text(\"最受欢迎\")","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find info: [debug] [BOOTSTRAP] [debug] 使用 ANDROID_UIAUTOMATOR 和 contextId 查找新的 UiSelector().text("Most Popular"):multiple: false 信息:[debug] [BOOTSTRAP] [debug] 解析选择器:new UiSelector().text("Most Popular") 信息:[调试] [BOOTSTRAP] [调试] UiSelector 强制类型:类 java.lang.String arg:“最受欢迎” 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[TEXT=Most Popular] 信息:[debug] [BOOTSTRAP] [debug] 未能找到元素。清除辅助功能缓存并重试。 info: [debug] [BOOTSTRAP] [debug] 使用 ANDROID_UIAUTOMATOR 和 contextId 查找新的 UiSelector().text("Most Popular"):multiple: false 信息:[debug] [BOOTSTRAP] [debug] 解析选择器:new UiSelector().text("Most Popular") 信息:[调试] [BOOTSTRAP] [调试] UiSelector 强制类型:类 java.lang.String arg:“最受欢迎” 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[TEXT=Most Popular] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":"No element found","status":7} 信息:[调试] 到目前为止等待了 115 毫秒 信息:[调试] 将命令推送到 appium 工作队列:["find",{"strategy":"-android uiautomator","selector":"new UiSelector().text(\"Most Popular\")","上下文":"","多个":false}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector ":"new UiSelector().text(\"最受欢迎\")","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find info: [debug] [BOOTSTRAP] [debug] 使用 ANDROID_UIAUTOMATOR 和 contextId 查找新的 UiSelector().text("Most Popular"):multiple: false 信息:[debug] [BOOTSTRAP] [debug] 解析选择器:new UiSelector().text("Most Popular") 信息:[调试] [BOOTSTRAP] [调试] UiSelector 强制类型:类 java.lang.String arg:“最受欢迎” 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[TEXT=Most Popular] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"ELEMENT":"4"},"status":0} 信息:[调试]成功响应客户端:{"status":0,"value":{"ELEMENT":"4"},"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0"} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/element {"using":"-android uiautomator","sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0" "value":"new UiSelector().text(\"Remix\")"} 信息:[调试] 等待 100000 毫秒的条件 信息:[debug] 将命令推送到 appium 工作队列:["find",{"strategy":"-android uiautomator","selector":"new UiSelector().text(\"Remix\")","context ":"","多个":false}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector ":"new UiSelector().text(\"Remix\")","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:find 信息:[调试] [BOOTSTRAP] [调试] 使用 ANDROID_UIAUTOMATOR 和 contextId 查找新的 UiSelector().text("Remix"):multiple:false 信息:[debug] [BOOTSTRAP] [debug] 解析选择器:new UiSelector().text("Remix") 信息:[调试] [BOOTSTRAP] [调试] UiSelector 强制类型:类 java.lang.String arg:“混音” 信息:[debug] [BOOTSTRAP] [debug] 使用:UiSelector[TEXT=Remix] 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"ELEMENT":"5"},"status":0} 信息:[调试]成功响应客户端:{"status":0,"value":{"ELEMENT":"5"},"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0"} 信息: POST /wd/hub/session/2c7f4312-23aa-4b5d-8b65-ae1f012797d0/touch/perform {"sessionId":"2c7f4312-23aa-4b5d-8b65-ae1f012797d0","actions":[{" action":"press","options":{"y":null,"x":null,"element":"4"}},{"action":"moveTo","options":{"y ":null,"x":null,"element":"5"}},{"action":"release","options":{}}]} 信息:[调试] 将命令推送到 appium 工作队列:["element:getLocation",{"elementId":"5"}] 信息:[debug] 将命令推送到 appium 工作队列:["element:getSize",{"elementId":"5"}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:getLocation","params":{"elementId":"5"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令操作:getLocation 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"y":1182,"x":525},"status":0} info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:getSize","params":{"elementId":"5"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:getSize 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"height":44,"width":118},"status":0} 信息:[debug] 将命令推送到 appium 工作队列:["element:getLocation",{"elementId":"4"}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:getLocation","params":{"elementId":"4"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令操作:getLocation 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"y":726,"x":478},"status":0} 信息:[debug] 将命令推送到 appium 工作队列:["element:getSize",{"elementId":"4"}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:getSize","params":{"elementId":"4"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:getSize 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"height":76,"width":212},"status":0} 信息:[调试] 将命令推送到 appium 工作队列:["element:getLocation",{"elementId":"5"}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:getLocation","params":{"elementId":"5"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令操作:getLocation 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"y":1182,"x":525},"status":0} 信息:[debug] 将命令推送到 appium 工作队列:["element:getSize",{"elementId":"5"}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:getSize","params":{"elementId":"5"}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:getSize 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":{"height":44,"width":118},"status":0} 信息:[调试] 将命令推送到 appium 工作队列:["element:touchDown",{"elementId":"4","x":584,"y":764}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:touchDown","params":{"elementId":"4","x ":584,"y":764}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:touchDown 信息:[调试] [BOOTSTRAP] [调试] 使用元素执行 TouchDown?真 x:584,y:764 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0} 信息:[调试] 将命令推送到 appium 工作队列:["element:touchMove",{"elementId":"5","x":584,"y":1204}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:touchMove","params":{"elementId":"5","x ":584,"y":1204}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:touchMove 信息:[调试] [BOOTSTRAP] [调试] 使用元素执行 TouchMove?真 x: 584, y: 1204 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0} 信息:[debug] 将命令推送到 appium 工作队列:["element:touchUp",{"elementId":"5","x":584,"y":1204}] info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"element:touchUp","params":{"elementId":"5","x ":584,"y":1204}} info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令 信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:touchUp 信息:[调试] [BOOTSTRAP] [调试] 使用元素执行 TouchUp?真 x: 584, y: 1204 信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0} 信息:[调试]成功响应客户端:{“status”:0,“value”:true,“sessionId”:“2c7f4312-23aa-4b5d-8b65-ae1f012797d0”} 信息:

当您想要滚动到的元素隐藏在当前屏幕视图下方时,请有人帮忙滚动屏幕

【问题讨论】:

  • 你到底想要什么.....向下滚动页面或将一个元素移动到另一个元素?
  • @noor 我想向下滚动页面。

标签: android appium python-appium


【解决方案1】:

首先,您可以通过以下方式进行:

//Scroll till element which contains "Views" text If It Is not visible on screen.
driver.scrollTo("Views");

// Scroll till element which contains Tabs text.
driver.scrollTo("Tabs");

这是您可以尝试的非常简单的方法。如果这对您没有帮助,您可以尝试以下代码:

Dimension size = driver.manage().window().getSize(); 
int starty = (int) (size.height * 0.80); 
//Find endy point which is at top side of screen. 
int endy = (int) (size.height * 0.20);
//int endy = (int) (size.height * 0.10);
//Find horizontal point where you wants to swipe. It is in middle of screen width. 
int startx = size.width / 2; 

//Swipe from Bottom to Top. 
driver.swipe(startx, starty, startx, endy, 3000); 

希望这会对你有所帮助。

【讨论】:

    【解决方案2】:

    // 创建一个方法名称 scrollTo 或您选择的任何名称,使用下面提到的代码,它将采用我们想要滚动的文本参数:(注意:这是在 java 中,您可以根据 python 语法进行转换)

    public void scrollTo(String text)
    {                
    driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\""+text+"\").instance(0))");
    }
    

    【讨论】:

      猜你喜欢
      • 2016-05-26
      • 1970-01-01
      • 1970-01-01
      • 2019-02-07
      • 1970-01-01
      • 2017-08-27
      • 2020-07-28
      • 2015-06-22
      • 2020-04-22
      相关资源
      最近更新 更多