---
# System prepended metadata

title: API Guide - deviceMan
tags: [Guide, API]

---

## Methods that TBot can call in getTestInput().
For query and control the app under test and system under test from inside the TBot execution.

==path=API.deviceMan==

## Description
group API of platform related routines

## Group Methods
1. **queryPassthroughOps**, path=API.deviceMan.queryPassthroughOps
    * Description: return the list of passthrough opcodes, including click, fillForm, submitForm, ...., etc.
    * Return Value: a list of passthrough opcodes, including click, fillForm, submitForm, ..., etc.
2. **restartApp**, path=API.deviceMan.restartApp
    * Description: restart the app
3. **peekUrlStatus**, path=API.deviceMan.peekUrlStatus
    * Description: return the HTTP request response status code!
    * Arguments:
        1. *url* : a url link.
    * Return Value: a dict that shows the key values in HTTP request response, including status code, url, version, msg, reason, and headers
4. **pokeRequestUrl**, path=API.deviceMan.pokeRequestUrl
    * Description: return the HTTP request response status code of a post method!
    * Arguments:
        1. *url* : a url link.
        2. *requestDict* : a dictionary for request parameters
    * Return Value: a dict that shows the key values in HTTP request response, including status code, url, version, msg, reason, and headers
5. **gotoUrl**, path=API.deviceMan.gotoUrl
    * Description: send out http request to the url. This only works when the SUT is web type and url is specified.
    * Arguments:
        1. *url* : a url link.
6. **queryInnerWindowSize**, path=API.deviceMan.queryInnerWindowSize
    * Description: get the inner window size of the device under test or the browser.
    * Return Value: a pair of integers for the size of the browser window in the view of the user.
7. **queryScrollWindowSize**, path=API.deviceMan.queryScrollWindowSize
    * Description: query for the whole window size that can be scrolled.
    * Return Value: the whole window size that can be scrolled.
8. **queryPlatformActions**, path=API.deviceMan.queryPlatformActions
    * Description: query actionables of the device (or browser) of the AuT.
    * Return Value: a list of dicts for the device (platform) actions.
9. **queryPlatformActionCount**, path=API.deviceMan.queryPlatformActionCount
    * Description: query the number of actionables of the device (or browser) of the AuT.
    * Return Value: the number of device (or browser) actions.
10. **getCookie**, path=API.deviceMan.getCookie
    * Description: ask Test-Dragon to get browser cookie for you.
    * Return Value: a list of cached data items by the pages.
11. **getLocalStorage**, path=API.deviceMan.getLocalStorage
    * Description: ask Test-Dragon to get browser local storage for you.
    * Return Value: a dict for cached data items by the pages.
12. **getScreenRawPageSource**, path=API.deviceMan.getScreenRawPageSource
    * Description: get the source html code of a url. If the url is not given, the current web page html code is returned.
    * Arguments:
        1. *url* : an http request target link, optoinal when the app under test is of web type.
    * Return Value: the source in XML or HTML of the DOM of the app current screenshot.
13. **clickScreenPosition**, path=API.deviceMan.clickScreenPosition
    * Description: make a click at the position of the device under test or browser.
    * Arguments:
        1. *x* : x-coordinate value of the positon
        2. *y* : y-coordinate value of the positon
14. **queryVolumeSUT**, path=API.deviceMan.queryVolumeSUT
    * Description: query the volume of the device of the AuT.
    * Arguments:
        1. *type* : the type of channel of the volume, default is MUSIC.
    * Return Value: the volume of the speaker.
15. **volumeUpSUT**, path=API.deviceMan.volumeUpSUT
    * Description: increase the volume of the device of the AuT.
16. **volumeDownSUT**, path=API.deviceMan.volumeDownSUT
    * Description: decrease the volume of the device of the AuT.
17. **menuKeySUT**, path=API.deviceMan.menuKeySUT
    * Description: emulate to depress the menu key of the device of the AuT.
18. **powerKeySUT**, path=API.deviceMan.powerKeySUT
    * Description: emulate to depress the power key of the device of the AuT.
19. **installAppSUT**, path=API.deviceMan.installAppSUT
    * Description: install the app at location appFilePath. This is only for Android apps at the moment.
    * Arguments:
        1. *appFilePath* : a file path for your app to install
20. **checkFileSystemCapacitySUT**, path=API.deviceMan.checkFileSystemCapacitySUT
    * Description: query the file system capacity of the device of the AuT.
    * Return Value: capacity of the device under test.
21. **apkMultitouchCheck**, path=API.deviceMan.apkMultitouchCheck
    * Description: check if the device can do multitouch
    * Arguments:
        1. *apkPath* : the path of apk file in your PC or macbook.
    * Return Value: True if the app under test accept multi-touch gesture. False if not. Can also be a string for error message.
22. **networkConnectionCheck**, path=API.deviceMan.networkConnectionCheck
    * Description: check the status of network connection of the device!
    * Return Value: the status of network connection.
23. **phonecallStateCheck**, path=API.deviceMan.phonecallStateCheck
    * Description: check the phone call session state.
    * Return Value: status of the phone call if the app under test runs on a phone.
24. **batterChange**, path=API.deviceMan.batterChange
    * Description: artificially change the battery power percentage.
    * Arguments:
        1. *percent* : a fraction for the remaining battery power to be set.
25. **addPhoneNumber**, path=API.deviceMan.addPhoneNumber
    * Description: add a phone number to the user data card.
    * Arguments:
        1. *pNr* : a phone number
26. **querySerialNumDUT**, path=API.deviceMan.querySerialNumDUT
    * Description: query for the serial number of the device under test.
    * Return Value: the serial number of the device under test.
27. **queryAttachedDevices**, path=API.deviceMan.queryAttachedDevices
    * Description: query for the devices that can be used to run the app under test.
    * Return Value: the list of devices attached to the computer.
28. **queryAttachedPhoneNr**, path=API.deviceMan.queryAttachedPhoneNr
    * Description: query for a phone number of a device connected to the computer.
    * Return Value: a phone number of a device (mobile phone) connected to the computer.
29. **getTimeUsage**, path=API.deviceMan.getTimeUsage
    * Description: check the time usage in the device running the app under test.
    * Arguments:
        1. *msg* : an optional message to display on CMD maybe for debugging.
    * Return Values form a list.
        1. The 1st element is the cpu time used by the app under test.
        2. The 2nd element is the wall clock time used by the app under test.
30. gpsAccess, path=API.deviceMan.gpsAccess
    * Description: get the GPS access state!
    * Return Value: the GPS access state.
31. **ApkinstallSdcardCheck**, path=API.deviceMan.ApkinstallSdcardCheck
    * Description: check the SD card status in the device under test
    * Return Value: the SD card status in the device under test.
32. **logcat**, path=API.deviceMan.logcat
    * Description: returns finding about special pattern in the log from the device under test.
    * Arguments:
        1. *pattern* : string for the target pattern to look in the log from the device under test.
    * Return Value: search result of the argument in the device logcat.
33. **notificationCheck**, path=API.deviceMan.notificationCheck
    * Description: returns the notifications on the device under test related to an app
    * Arguments:
        1. *packageName* : the target app to look at!
    * Return Value: the notifications on the device under test related to the argument as package name.
34. **instantiateWebDriver**, path=API.deviceMan.instantiateWebDriver
    * Description: start a browser
    * Arguments:
        1. *browserID* : the Identifier of browsers, can be chrome, firefox, safari, edge.
        2. *browserProfileDirPath* : a path to a folder containing all profile info for this driver
        3. *browserConfig* : a python dict about some special configuration to launch the browser. Default is None.
        4. *downloadDir* : a directory path for saving files downloaded by the browser instance.
        5. *flagUsedAsDuT* : True if and only if this driver is used as the driver under test for the test session.
35. **quitWebdriver**, path=API.deviceMan.quitWebdriver
    * Description: quit a browser
    * Arguments:
        1. *driver* : the driver to quit. If not given, the driver in the current test session will quit.
36. **queryBrowserId**, path=API.deviceMan.queryBrowserId
    * Description: query for the browser Id, can be chrome, firefox, edge, safari, ...
    * Return Value: the name of the browser.
37. **getAppStatus**, path=API.deviceMan.getAppStatus
    * Description: get the CPU time, memory usage, and etc. of the AuT in its device under test.
    * Return Value: CPU time, memory usage, and etc. of the AuT in its device under test.
38. **checkOutOfApp**, path=API.deviceMan.checkOutOfApp
    * Description: check if the screenshot is no longer of the App under Test (AuT).
    * Return Value: True if the device under test (or brower) is still in the domain of the app under test. False otherwise.
39. **backgroundCheck**, path=API.deviceMan.backgroundCheck
    * Description: check if the app of packageName is in background.
    * Arguments:
        1. *packageName* : an app name.
    * Return Value: True if the app of packageName is in background. False otherwise. If packageName is None, the app under test is used inplace.
40. **checkForegroundActivitySUT**, path=API.deviceMan.checkForegroundActivitySUT
    * Description: query the application that is in the foreground of the device under test.
    * Return Value: the activity name in the foreground of the device under test.
41. **checkActionable**, path=API.deviceMan.checkActionable
    * Description: check if actionable indexed gai in the current screenshot is actually actionable.
    * Arguments:
        1. *gai* : the action index in the legal action list! Note that this is not the all action index.
    * Return Value: True if the gai'th element in the legal action list is actually actionable. False otherwise.
42. **installationCheck**, path=API.deviceMan.installationCheck
    * Description: check if an app is installed in the device under test.
    * Arguments:
        1. *packageName* : an app name.
    * Return Value: True if app packageName is installed in the device under test. False otherwise.
43. **cmdToDUT**, path=API.deviceMan.cmdToDUT
    * Description: send a list of command components (in the style of subprocess) to the Device under test for App under Test
    * Arguments:
        1. *commandCompList* : a list of command components
        2. *flagPopen* : True if no output return is needed.
    * Return Value: execution result of the device under test.
44. **cmdToSSh**, path=API.deviceMan.cmdToSSh
    * Description: send a list of command components (in the style of subprocess) to a scoket via SSH.
    * Arguments:
        1. *hostName* : a host name
        2. *userName* : the login user name to SSh.
        3. *password* : the login user password to SSh.
        4. *port* : a port number
        5. *commandCompList* : a list of command components
    * Return Value: execution result of the SSH socket.