Kepler automation through the Appium Kepler driver is working correctly with both JavaScript and Python clients.
However, when running the same logic via Java, the script executes successfully (no errors reported), but DPAD navigation input events do not take effect on the Vega emulator/device.
Attachments / Repro Steps:
-
Start Appium server and Kepler emulator.
-
Run the Java sample below (attached).
-
Observe no navigation even though execution completes successfully.
Code Sample:
package com.logituit.sample;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.remote.options.BaseOptions;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class ExecuteScriptExample {
public static void main(String[] args) throws MalformedURLException {
BaseOptions options = new BaseOptions()
.setPlatformName("Kepler")
.setAutomationName("automation-toolkit/JSON-RPC")
.amend("kepler:device", "vda://emulator-5554")
.amend("appium:appURL", "com.amazondeveloper.keplervideoapp");
AppiumDriver driver = new AppiumDriver(new URL("http://localhost:4723"), options);
try {
String output = driver.executeScript("shell", "echo 'Hello World!'").toString();
System.out.println(output);
Map<String, Object> params = new HashMap<>();
params.put("inputKeyEvent", "108");
params.put("holdDuration", 0);
driver.executeScript("jsonrpc: injectInputKeyEvent", new Object[]{params});
System.out.println("✅ Sent one D-Pad DOWN key event.");
} finally {
driver.quit();
}
}
}
Hi @Thimmanna
Thanks for sharing this issue. Please allow us some time to come back to you with a solution.
Warm Regards,
Ivy
Hello @Thimmanna
Could you share the log of appium to us?
I also see the holdDuration is 0
could you set it to 1 seconds to check?(duration unit is ms or sec?)
Hi @Wenguang_Hu
I also tried by changing holdDuration as well, i see no changes in the behaviour.
Please find the appium logs below.
CLI: Launch URI: orpheus://com.amazondeveloper.keplervideoapp
childProcessExec succeeded after 392ms
Successfully activated app com.amazondeveloper.keplervideoapp
Running childProcessExec( vda -s emulator-5554 forward tcp:15000 tcp:8383 on test host...
childProcessExec STDOUT: 15000
childProcessExec succeeded after 352ms
[AppiumDriver@db0c] New KeplerDriver session created successfully, session 3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab added to master session list
[AppiumDriver@db0c] Event 'newSessionStarted' logged at 1763532343731 (11:35:43 GMT+0530 (India Standard Time))
[KeplerDriver@0394] Cached the protocol value 'W3C' for the new session 3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab
[KeplerDriver@0394] Responding to client with driver.createSession() result: {"capabilities":{"kepler:device":"vda://emulator-5554","platformName":"Kepler","appURL":"com.amazondeveloper.keplervideoapp","automationName":"automation-toolkit/JSON-RPC"}}
[HTTP] <-- POST /session 200 1246 ms - 234
[HTTP] --> POST /session/3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab/execute/sync {"script":"shell","args":["echo 'Hello World!'"]}
[KeplerDriver@0394] Calling AppiumDriver.execute() with args: ["shell",["echo 'Hello World!'"],"3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab"]
Running /executeScript with script=execute, args=[
'shell',
[ "echo 'Hello World!'", [length]: 1 ],
'3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab',
[length]: 3
]
Running /executeScript with script=shell, args=[ "echo 'Hello World!'", [length]: 1 ]
Executing SHELL command: echo 'Hello World!'
Running childProcessExec( vda -s emulator-5554 shell 'echo 'Hello World!' || echo SHELL_COMMAND_FAILED' on test host...
childProcessExec STDOUT: Hello World!
childProcessExec succeeded after 361ms
[KeplerDriver@0394] Responding to client with driver.execute() result: "Hello World!\n"
[HTTP] <-- POST /session/3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab/execute/sync 200 364 ms - 26
[HTTP] --> POST /session/3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab/execute/sync {"script":"jsonrpc: injectInputKeyEvent","args":[{"holdDuration":10,"inputKeyEvent":"108"}]}
[KeplerDriver@0394] Calling AppiumDriver.execute() with args: ["jsonrpc: injectInputKeyEvent",[{"holdDuration":10,"inputKeyEvent":"108"}],"3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab"]
Running /executeScript with script=execute, args=[
'jsonrpc: injectInputKeyEvent',
[ { holdDuration: 10, inputKeyEvent: '108' }, [length]: 1 ],
'3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab',
[length]: 3
]
Running /executeScript with script=jsonrpc: injectInputKeyEvent, args=[ { holdDuration: 10, inputKeyEvent: '108' }, [length]: 1 ]
Executing JSON RPC method: 'jsonrpc: injectInputKeyEvent'
Sending jsonRPC POST http://127.0.0.1:15000/jsonrpc id=0, method=injectInputKeyEvent, params undefined=undefined
received jsonrpc response in 6ms (http 200 OK): {"error":{"code":-32602,"message":"INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised"},"id":"0","jsonrpc":"2.0"}
[KeplerDriver@0394] Responding to client with driver.execute() result: {"error":{"code":-32602,"message":"INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised"},"id":"0","jsonrpc":"2.0"}
[HTTP] <-- POST /session/3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab/execute/sync 200 8 ms - 152
[HTTP] --> DELETE /session/3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab {}
[KeplerDriver@0394] Calling AppiumDriver.deleteSession() with args: ["3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab"]
[AppiumDriver@db0c] Event 'quitSessionRequested' logged at 1763532344178 (11:35:44 GMT+0530 (India Standard Time))
[AppiumDriver@db0c] Removing session 3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab from our master session list
Running childProcessExec( vda -s emulator-5554 shell 'ls /tmp | grep automation-toolkit.service' on test host...
childProcessExec STDOUT: systemd-private-09583369ce604b4da77c1ff9ff1a6fdf-automation-toolkit.service-Uw8MBb
childProcessExec succeeded after 374ms
Running childProcessExec( vda -s emulator-5554 shell 'test -f /tmp/systemd-private-09583369ce604b4da77c1ff9ff1a6fdf-automation-toolkit.service-Uw8MBb/tmp/atk_screen_capture.mp4; echo $?' on test host...
childProcessExec STDOUT: 1
childProcessExec succeeded after 362ms
Running childProcessExec( vda -s emulator-5554 forward --remove tcp:15000 || true on test host...
childProcessExec succeeded after 351ms
[AppiumDriver@db0c] Event 'quitSessionFinished' logged at 1763532345267 (11:35:45 GMT+0530 (India Standard Time))
[AppiumDriver@db0c] Received response: null
[AppiumDriver@db0c] But deleting session, so not returning
[AppiumDriver@db0c] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /session/3ff9f80f-68e7-45a6-b2bd-9ba19c2a92ab 200 1089 ms - 14
Hello @Thimmanna
according to your appium log
I see
{"error":{"code":-32602,"message":"INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised"},"id":"0","jsonrpc":"2.0"}
it seems the parameter is invalid
Could you try
try { driver().executeScript("jsonrpc: injectInputKeyEvent",
List.of(Map.of(
"inputKeyEvent", "108",
"holdDuration", 100
)));
} finally {
driver.quit();
}
My appium log looks like that
[7153596b][KeplerDriver@5be8] Calling AppiumDriver.execute() with args: [“jsonrpc: injectInputKeyEvent”,[[{“inputKeyEvent”:“108”,“holdDuration”:100}]],“7153596b-4444-4018-8f87-5b6d24db5a30”]
Running /executeScript with script=execute, args=[
‘jsonrpc: injectInputKeyEvent’,
[
[ { inputKeyEvent: ‘108’, holdDuration: 100 }, [length]: 1 ],
[length]: 1
],
‘7153596b-4444-4018-8f87-5b6d24db5a30’,
[length]: 3
]
Running /executeScript with script=jsonrpc: injectInputKeyEvent, args=[
[ { inputKeyEvent: ‘108’, holdDuration: 100 }, [length]: 1 ],
[length]: 1
]
Executing JSON RPC method: ‘jsonrpc: injectInputKeyEvent’
Sending jsonRPC POST ``http://127.0.0.1:15281/jsonrpc`` id=0, method=injectInputKeyEvent, params object={“inputKeyEvent”:“108”,“holdDuration”:100}
received jsonrpc response in 107ms (http 200 OK): {“id”:“0”,“jsonrpc”:“2.0”,“result”:true}
[7153596b][KeplerDriver@5be8] Responding to client with driver.execute() result: {“id”:“0”,“jsonrpc”:“2.0”,“result”:true}
[7153596b][HTTP] ← POST /session/7153596b-4444-4018-8f87-5b6d24db5a30/execute/sync 200 108 ms - 50
Thanks @Wenguang_Hu ,
Slightly modifying the code snippet you provided and importing necessary dependencies, worked for me.
here is the updated code that worked for me
driver.executeScript("jsonrpc: injectInputKeyEvent",
List.of(Map.of(
"inputKeyEvent", "108",
"holdDuration", 100
)));
1 Like