appium / appium/java-client

Android 9 can't get system bars

Open
#1,228 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
1.3k
Forks
752
Avg merge
6d 21h
Merged PRs (30d)
8

Description

The problem

There is a problem in java-client-7.2.0 。The return type of HasAndroidDeviceDetails.getSystemBars,but actually is Map<String, Map<String,String>>。The response data is : {statusBar={visible=true, x=0, y=0, width=1080, height=89}, navigationBar={visible=true, x=0, y=0,width=1080, height=130}} 。Errors are reported as follows:
java.lang.ClassCastException: com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to java.lang.String

Environment

  • Appium version (or git revision) that exhibits the issue:7.2.0
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium:windows 7
  • Node.js version (unless using Appium.app|exe): 12.9.1
  • Npm or Yarn package manager:npm
  • Mobile platform/version under test: android 9
  • Real device or emulator/simulator:Real device MI8
  • Appium CLI or Appium.app|exe:

Code To Reproduce Issue [ Good To Have ]

	Map<String,String> bars= driver.getSystemBars();
	for(Entry<String, String> entry: bars.entrySet())
	{
		System.out.println("key:"+entry.getKey()+",value:"+entry.getValue());

            }

##error log
java.lang.ClassCastException: com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to java.lang.String
at com.liu.jointt.test.HelloTest.testApi(HelloTest.java:432)
at com.liu.jointt.test.HelloTest.testAll(HelloTest.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

service log

[debug] [UiAutomator2] Getting session details from server to mix in
[debug] [WD Proxy] Matched '/' to command name 'getSession'
[debug] [WD Proxy] Proxying [GET /] to [GET http://localhost:8200/wd/hub/session
/b3d59c58-4570-426a-90c8-ec6742b53472] with body: {}
[debug] [WD Proxy] Got response with status 200: "{"sessionId":"b3d59c58-4570
-426a-90c8-ec6742b53472","status":0,"value":{}}"
[debug] [W3C (7f8e0ffa)] Responding to client with driver.getSession() result: {
"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptE
nabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationCo
ntextEnabled":false,"warnings":{},"desired":{"browserName":"","platformName":"an
droid","sessionOverride":true,"unicodekeyboard":"true","app":"E:\workspace_andr
iod\prototype\app\KPI.apk","deviceName":"dff48a9d","platformVersion":"9","res
etKeyboard":true},"browserName":"","platformName":"android","sessionOverride":tr
ue,"unicodekeyboard":"true","app":"E:\workspace_andriod\prototype\app\KPI.ap
k","deviceName":"dff48a9d","platformVersion":"9","resetKeyboard":true,"deviceUDI
D":"dff48a9d","appPackage":"com.jointt.myapp","deviceApiLevel":28,"deviceScreenS
ize":"1080x2248","deviceScreenDensity":440,"deviceModel":"MI 8","deviceManufactu
rer":"Xiaomi","pixelRatio":2.75,"statBarHeight":89,"viewportRect":{"left":0,"top
":89,"width":1080,"height":1940}}
[HTTP] <-- GET /wd/hub/session/7f8e0ffa-df5f-404b-a20d-c69fc5c2cc48 200 25 ms -
924
[HTTP]
[HTTP] --> GET /wd/hub/session/7f8e0ffa-df5f-404b-a20d-c69fc5c2cc48/appium/devic
e/system_bars
[HTTP] {}
[debug] [W3C (7f8e0ffa)] Calling AppiumDriver.getSystemBars() with args: ["7f8e0
ffa-df5f-404b-a20d-c69fc5c2cc48"]
[debug] [ADB] Running 'C:\Program Files\Andriod\android-sdk\platform-tools\adb.e
xe -P 5037 -s dff48a9d shell dumpsys window windows'
[debug] [W3C (7f8e0ffa)] Responding to client with driver.getSystemBars() result
: {"statusBar":{"visible":true,"x":0,"y":0,"width":1080,"height":89},"navigation
Bar":{"visible":true,"x":0,"y":0,"width":1080,"height":130}}
[HTTP] <-- GET /wd/hub/session/7f8e0ffa-df5f-404b-a20d-c69fc5c2cc48/appium/devic
e/system_bars 200 98 ms - 148
[HTTP]
[HTTP] --> DELETE /wd/hub/session/7f8e0ffa-df5f-404b-a20d-c69fc5c2cc48
[HTTP] {}
[debug] [W3C (7f8e0ffa)] Calling AppiumDriver.deleteSession() with args: ["7f8e0
ffa-df5f-404b-a20d-c69fc5c2cc48"]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the HasAndroidDeviceDetails.getSystemBars() API and compare its declared return type with the nested response shown from /appium/device/system_bars. Reproduce the ClassCastException with driver.getSystemBars(), then inspect the related Java client tests or API definitions. Done means the returned system-bar data can be consumed without the reported cast failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
api, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.