---
# System prepended metadata

title: API Guide - stateAna
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.stateAna==

## Description
state analysis API group

## Group Methods
1. **queryActionList**, path=API.stateAna.queryActionList
    * Description: all actions of the current state of the app under test.
    * Return Value: a list of all actions on either the current app screen or the device (or browser).
2. **queryLegalActionList**, path=API.stateAna.queryLegalActionList
    * Description: actions visible on the screen at the current state of the app under test
    * Return Value: a list of actionable actions on either the app screen or the device (or browser).
3. **queryFormDicts**, path=API.stateAna.queryFormDicts
    * Description: dicts of the forms recognized by our mega test robot from the current screen
    * Return Value: a list of forms recognized by TestDragon.
4. **queryScreenshotImg**, path=API.stateAna.queryScreenshotImg
    * Description: get the opencv (numpy) image of the app screenshot.
    * Arguments:
        1. *flagForcedDump* : True to force dump from the device or browser. Default (False) is use the already saved image if possible.
    * Return Value: the opencv object (i.e., numpy with some methods and attributes of opencv) for the current screenshot.
5. **queryScreenshotImgSize**, path=API.stateAna.queryScreenshotImgSize
    * Description: get the opencv (numpy) image size of the app screenshot.
    * Return Value: a pair of integers for width and height of the app current screenshot.
6. **queryCurActivity**, path=API.stateAna.queryCurActivity
    * Description: get an id for the activity of the current screen state of the app under test.
    * Return Value: an id string for the current screenshot.
7. **getCurrentScreenLayoutHashIndex**, path=API.stateAna.getCurrentScreenLayoutHashIndex
    * Description: get a hash value for the activity of the current screen state of the app under test.
    * Return Value: a hash value string for the current screenshot.
8. **queryAutomataDict**, path=API.stateAna.queryAutomataDict
    * Description: return the ordinary state automata constructed in this test session.
    * Return Value: a list for all states of the current automata accumulated in the current test session.
9. **queryScreenActionCount**, path=API.stateAna.queryScreenActionCount
    * Description: returns the number of actions visible on the screen of the current state of the App under test
    * Return Value: an integer for the number of actions on the app current screenshot.
10. **queryCurrentStateIndex**, path=API.stateAna.queryCurrentStateIndex
    * Description: query the state index of the current screenshot in the automata dict.
    * Return Value: an integer for the state index of the dom of the current screenshot.
11. **queryLastAction**, path=API.stateAna.queryLastAction
    * Description: query for the last screen or device action.
    * Return Value: a dict for an action record.
12. **queryDomErrors**, path=API.stateAna.queryDomErrors
    * Description: query for the error message in the DOM.
    * Return Value: a list for the error messages in the DOM. At the moment, only body and h1 tags matter.
13. **queryDomDict**, path=API.stateAna.queryDomDict
    * Description: query the dome dict of the current screenshot.
    * Return Value: a dict for the condensed DOM structure of the app current screenshot.
14. **queryCountStateLeaves**, path=API.stateAna.queryCountStateLeaves
    * Description: query the leaves (terminal elements) of the dom dict of the current screenshot.
    * Return Value: an integer for the number of leaves in the condensed DOM structure of the app current screenshot.
15. **queryFlagScreenStateAnalysis**, path=API.stateAna.queryFlagScreenStateAnalysis
    * Description: check if screen analysis is on. If it is on, then you will see the legal action list, forms, and component topics of each screen. The default is on.
    * Return Value: True if screen DOM analysis is turned on. False otherwise.
16. **startScreenStateAnalysis**, path=API.stateAna.startScreenStateAnalysis
    * Description: turn on the switch of screen analysis.
17. **stopScreenStateAnalysis**, path=API.stateAna.stopScreenStateAnalysis
    * Description: turn off the switch of screen analysis.
18. **queryCoverageAutomata**, path=API.stateAna.queryCoverageAutomata
    * Description: return the state list of the coverage automata for this project. Note that each app of a version has its own coverage automata.
    * Return Value: the state list of the coverage automata.
19. **queryCoverageState**, path=API.stateAna.queryCoverageState
    * Description: return the state index and state dict of the current state in the coverage automata for this project. Note that each app of a version has its own coverage automata.
    * Arguments:
        1. *covStateIndex* : If this is not None, then we simply return the coverage automata state of this index value. Else, the coverage state of the current state is returned.
    * Return Value: the state index of the current state in the coverage automata if the argument is None. Otherwise the state indexed by the argument in the coverage automata.
20. **queryCA_allStateCount**, path=API.stateAna.queryCA_allStateCount
    * Description: return the number of states in the coverage automata for this project. Note that each app of a version has its own coverage automata.
    * Return Value: an integer for the number of states in the coverage automata.
21. **queryCA_allActionCount**, path=API.stateAna.queryCA_allActionCount
    * Description: returns the action counts of all coverage states in the coverage automata for this project. Note that each app of a version has its own coverage automata.
    * Return Value: the number for all actions in all states in the coverage automata.
22. **queryCA_allActionCoverage**, path=API.stateAna.queryCA_allActionCoverage
    * Description: returns the coverage of triggered actions in the coverage automata for this project. Note that each app of a version has its own coverage automata.
    * Return Value: the percentage of triggered actions in all actions of all states in the coverage automata.
23. **queryCA_allScreenActionCount**, path=API.stateAna.queryCA_allScreenActionCount
    * Description: returns the number of all screen actions in the coverage automata for this project. Note that each app of a version has its own coverage automata.
    * Return Value: the number of triggered actions in all screen actions of all states in the coverage automata.
24. **queryCA_AllScreenActionCoverage**, path=API.stateAna.queryCA_AllScreenActionCoverage
    * Description: returns the coverage of all triggered screen actions in the coverage automata for this project. Note that each app of a version has its own coverage automata.
    * Return Value: the percentage of triggered actions in all screen actions of all states in the coverage automata.
25. **queryUncircularDomDict**, path=API.stateAna.queryUncircularDomDict
    * Description: returns a simplified dict by removing duplicacy.
    * Return Value: a dict for the condensed DOM structure of the app current screenshot by removing cyclic references.
26. **queryCurrentUrlPath**, path=API.stateAna.queryCurrentUrlPath
    * Description: get the url of the current web page, if available.
    * Return Value: the url of the current screenshot if the app is a web application.
27. **queryCoverage**, path=API.stateAna.queryCoverage
    * Description: query the indices of covered and uncovered actionable elements in the current test session.
    * Return Value: a dict for action coverage information.
28. **getCoverageCounts**, path=API.stateAna.getCoverageCounts
    * Description: get the various counts of coverage estimation.
    * Return Value: a dict for all coverage information.