Closed liqing380 closed 8 years ago
Hmm @bootstraponline what do you think? A problem with the UiSelector code?
The best way to isolate these kinds of problems is to try a pure Java uiautomator approach to see if the problem exists. Then we can tell if it's an appium problem or a uiautomator one.
Could not parse Ui Selector argument: problem using reflection to call this method
seems like something wrong with the appium code or maybe the supplied Java string isn't valid.
@bootstraponline what does a pure Java uiautomator approach mean ?
@bootstraponline
then i try:
HashMap<String, String> scrollObject = new HashMap<String, String>();
RemoteWebElement element = (RemoteWebElement)appDriver.findElementByAndroidUIAutomator(
"new UiSelector().className(\"android.widget.ListView\")");
JavascriptExecutor js = (JavascriptExecutor) appDriver;
String webElementId = ((RemoteWebElement) element).getId();
scrollObject.put("text", "More mail");
scrollObject.put("element", webElementId);
js.executeScript("mobile: scrollTo", scrollObject);
_it works well ._
appium.log:
C:\Users\mailtech>appium -U NX507J -p 4727 -bp 4737 --no-reset
info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
info: Appium REST http interface listener started on 0.0.0.0:4727
info: [debug] Non-default server args: {"udid":"NX507J","port":4727,"bootstrapPo
rt":4737,"noReset":true}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"newCommandTimeout":"600"
,"platformVersion":"4.4","platformName":"Android","deviceName":"Android","appAct
ivity":"cn.mailtech.app.activity.SplashMailtech","browserName":"","appPackage":"
cn.mailtech.app"}}
info: Client User-Agent string: Apache-HttpClient/4.3.2 (java 1.5)
info: [debug] Didn't get app but did get Android package, will attempt to launch
it on the device
info: [debug] Creating new appium session 56461b42-5e85-4c72-b1ef-3a6a95c466d2
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.7.0_21
info: [debug] Using fast reset? false
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it's alr
eady on the device
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device NX507J
info: [debug] Setting device id to NX507J
info: [debug] Waiting for device to be ready and to respond to shell commands (t
imeout = 5)
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J wait-for-device
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J shell "echo 'ready'"
info: [debug] Starting logcat capture
warn: No app capability, can't parse package/activity
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: Device API level is: 19
info: [debug] Apk doesn't exist locally
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J shell "rm -rf /data/local/tmp/strings.json"
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an ap
p path
info: [debug] Forwarding system:4737 to device:4724
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J forward tcp:4737 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J push "C:\\Users\\mailtech\\AppData\\Roaming\\npm\\node_m
odules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J install "C:\Users\mailtech\AppData\Roaming\npm\node_modu
les\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J install "C:\Users\mailtech\AppData\Roaming\npm\node_modu
les\appium\build\unlock_apk\unlock_apk-debug.apk"
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools
\adb.exe -s NX507J shell uiautomator runtest AppiumBootstrap.jar -c io.appium.an
droid.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRun
ner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.andro
id.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"wake","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"getDataDir","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data\/local\/tmp
","status":0}
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy"
,{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J shell "am start -S -a android.intent.action.MAIN -c andr
oid.intent.category.LAUNCHER -f 0x10200000 -n cn.mailtech.app/cn.mailtech.app.ac
tivity.SplashMailtech"
info: [debug] Waiting for pkg "cn.mailtech.app" and activity "cn.mailtech.app.ac
tivity.SplashMailtech" to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J shell "dumpsys window windows"
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to 600 secs
info: [debug] Appium session started with sessionId 56461b42-5e85-4c72-b1ef-3a6a
95c466d2
info: <-- POST /wd/hub/session 303 5528.897 ms - 9
info: --> GET /wd/hub/session/56461b42-5e85-4c72-b1ef-3a6a95c466d2 {}
info: [debug] Responding to client with success: {"status":0,"value":{"platform"
:"LINUX","browserName":"","platformVersion":"4.4","webStorageEnabled":false,"tak
esScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConn
ectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"new
CommandTimeout":"600","platformVersion":"4.4","platformName":"Android","deviceNa
me":"Android","appActivity":"cn.mailtech.app.activity.SplashMailtech","browserNa
me":"","appPackage":"cn.mailtech.app"},"newCommandTimeout":"600","platformName":
"Android","deviceName":"Android","appActivity":"cn.mailtech.app.activity.SplashM
ailtech","appPackage":"cn.mailtech.app"},"sessionId":"56461b42-5e85-4c72-b1ef-3a
6a95c466d2"}
info: <-- GET /wd/hub/session/56461b42-5e85-4c72-b1ef-3a6a95c466d2 200 4.731 ms
- 683 {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion"
:"4.4","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true
,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled
":false,"warnings":{},"desired":{"newCommandTimeout":"600","platformVersion":"4.
4","platformName":"Android","deviceName":"Android","appActivity":"cn.mailtech.ap
p.activity.SplashMailtech","browserName":"","appPackage":"cn.mailtech.app"},"new
CommandTimeout":"600","platformName":"Android","deviceName":"Android","appActivi
ty":"cn.mailtech.app.activity.SplashMailtech","appPackage":"cn.mailtech.app"},"s
essionId":"56461b42-5e85-4c72-b1ef-3a6a95c466d2"}
info: --> POST /wd/hub/session/56461b42-5e85-4c72-b1ef-3a6a95c466d2/element {"us
ing":"-android uiautomator","value":"new UiSelector().className(\"android.widget
.ListView\")"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"-androi
d uiautomator","selector":"new UiSelector().className(\"android.widget.ListView\
")","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector()
.className(\"android.widget.ListView\")","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding new UiSelector().className("android.wi
dget.ListView") using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().className("
android.widget.ListView")
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: java.lang.Class<T> arg
: "android.widget.ListView"
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String
arg: "android.widget.ListView"
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.ListVie
w]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"1"},"st
atus":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":
"1"},"sessionId":"56461b42-5e85-4c72-b1ef-3a6a95c466d2"}
info: <-- POST /wd/hub/session/56461b42-5e85-4c72-b1ef-3a6a95c466d2/element 200
98.968 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"56461b42-5e85-4c
72-b1ef-3a6a95c466d2"}
info: --> POST /wd/hub/session/56461b42-5e85-4c72-b1ef-3a6a95c466d2/execute {"ar
gs":[{"element":"1","text":"More mail"}],"script":"mobile: scrollTo"}
warn: scrollTo will be removed in a future version of appium
info: [debug] Pushing command to appium work queue: ["element:scrollTo",{"text":
"More mail","direction":"vertical","elementId":"1"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"element:scrollTo","params":{"text":"More mail","direction":"vertical","element
Id":"1"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: scrollTo
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessi
onId":"56461b42-5e85-4c72-b1ef-3a6a95c466d2"}
info: <-- POST /wd/hub/session/56461b42-5e85-4c72-b1ef-3a6a95c466d2/execute 200
6601.843 ms - 76 {"status":0,"value":true,"sessionId":"56461b42-5e85-4c72-b1ef-3
a6a95c466d2"}
info: --> DELETE /wd/hub/session/56461b42-5e85-4c72-b1ef-3a6a95c466d2 {}
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-
tools\adb.exe -s NX507J shell "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down"
,"status":0}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRun
ner
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.andro
id.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 19.389
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Responding to client with success: {"status":0,"value":null,"sessi
onId":"56461b42-5e85-4c72-b1ef-3a6a95c466d2"}
info: <-- DELETE /wd/hub/session/56461b42-5e85-4c72-b1ef-3a6a95c466d2 200 932.76
7 ms - 76 {"status":0,"value":null,"sessionId":"56461b42-5e85-4c72-b1ef-3a6a95c4
66d2"}
Yeah but we want to deprecate those mobile:
executescript commands.
I guess we need to figure out the difference on Android between scrollTo and uiselector scrolling. Ideally we'd offer both (even if it's not part of mobile:
) so that users can always find something that works.
HI , Any Solutions for this so far ?
Thanks Fredrick
@fsuresh @liqing380 this should be fixed with 1.4.0-beta
can you check?
Do you mean appium 1.4.0-beta ?
yes
I installed Appium 1.4 now , but still the scrollTo is not working properly
@fsuresh sorry for delayed response. Can you upgrade to latest appium version. We fixed scrollTo earlier
Closing this according to #385
my java code:
the text “More mail” is in a scrollable android.widget.ListView. with appium1.2.0+java-client1.7.0+AppiumDriver :
AppiumDriver.scrollTo("More mail");
works well,it first swipe down to refresh the list and then drag back and forth until find the element.but with appium1.3.4+java-client2.1.0+AndroidDriver : it not scrolled and tap another element which above the edge of the android.widget.ListView like this:it it tap the INBOX (or the edge of the blue color bar ) and not perform scrollTo "More mail": i guess it tap beyong or on the upper border of the android.widget.ListView when perform scrollTo:
java error:
appium.log: