提取 UIATableCell 值
Extract UIATableCell value
我正在研究 iOS-ui-Automation 并想提取 UIATableCell 值。程序如下:
- 检查 table 视图是否存在
- 第一个单元格中的内容
以下 TEST.JS 的代码片段用于测试应用程序:
.
.
.
if ( target.frontMostApp().mainWindow().tableViews()[0].checkIsValid() )
{
UIALogger.logStart("Table view recognized ...");
target.delay(2.0);
var TableViewInfo = target.frontMostApp().mainWindow().tableViews()[0].cells()[0]
UIALogger.logStart(TableViewInfo);
}
在仪器日志中,我看到以下内容:
UIATableView "(null)" {{99, 99}, {99, 99}}
elements: {
UIATableCell "xyz" {{99, 99}, {99, 99}}
elements: {
UIAStaticText "xyz" {{99, 99}, {99, 99}}
UIAWebView "(null)" {{99, 99}, {99, 99}}
elements: {
UIAStaticText "xyz." {{99, 99}, {99, 99}}
}
}
如何读出 "xyz" 并在 TEST.JS 中登出?
要从元素中提取 "xyz" 字符串,您应该能够在其上使用 .name()
method。
在这种情况下,看起来应该是 TableViewInfo.cells()[0].name()
。
另外,您始终可以使用 logElementTree() 方法。它会在调用时将元素层次结构打印到跟踪日志中。
例如:tableViews()[0].logElementTree();
我正在研究 iOS-ui-Automation 并想提取 UIATableCell 值。程序如下:
- 检查 table 视图是否存在
- 第一个单元格中的内容
以下 TEST.JS 的代码片段用于测试应用程序:
.
.
.
if ( target.frontMostApp().mainWindow().tableViews()[0].checkIsValid() )
{
UIALogger.logStart("Table view recognized ...");
target.delay(2.0);
var TableViewInfo = target.frontMostApp().mainWindow().tableViews()[0].cells()[0]
UIALogger.logStart(TableViewInfo);
}
在仪器日志中,我看到以下内容:
UIATableView "(null)" {{99, 99}, {99, 99}}
elements: {
UIATableCell "xyz" {{99, 99}, {99, 99}}
elements: {
UIAStaticText "xyz" {{99, 99}, {99, 99}}
UIAWebView "(null)" {{99, 99}, {99, 99}}
elements: {
UIAStaticText "xyz." {{99, 99}, {99, 99}}
}
}
如何读出 "xyz" 并在 TEST.JS 中登出?
要从元素中提取 "xyz" 字符串,您应该能够在其上使用 .name()
method。
在这种情况下,看起来应该是 TableViewInfo.cells()[0].name()
。
另外,您始终可以使用 logElementTree() 方法。它会在调用时将元素层次结构打印到跟踪日志中。
例如:tableViews()[0].logElementTree();