I need to validate few status of the android device. Can any one let me know how to extract the information from adb dumpsys and validate the responses using Java. Your help is much appreciated.

Ex: 'adb shell dumpsys battery' this code when android device is connected to windows gets executed and will fetch the response. can someone help me how to extract the information from response and validate the same.

1 Answer 1

    Map<String, Object> argv = new HashMap<>();
    argv.put("command", "dumpsys ");
    argv.put("args", Lists.newArrayList("battery"));
    String result = ((AppiumDriver) driver).executeScript("mobile: shell", argv).toString();
  • 1
    Welcome to SQA Stack exchange! You answer could be much better if you were to add some explanation to your code.
    – Kate Paulk
    Commented Dec 14, 2022 at 13:29
  • Also, you could simply have added a comment and put a link to your older exact same answer on StackOverflow (or vice versa).
    – Andreas
    Commented Jan 8 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.