如何以编程方式在我的自动化脚本中获取 UI 层次结构?

How to programatically get the UI Hierarchy in my automation script?

我试图将 target.logElementTree 的结果在自动化过程中存储在一个变量中。试过:

var op = target.logElementTree();
UIALogger.logMessage(op);

日志结果将是 "null value" 所以我想弄清楚如何通过在执行期间存储它来访问该信息..

IN SHORT " I want to store the result of target.logElementTree() which is one way of doing it I believe.

感谢您抽出宝贵的时间进行到最后。

logElementTree 写入日志,而不是 return 值。从代码中获取层次结构的唯一方法是自己递归遍历它,例如visiting the .elements() array of each element.