我能够看到视图,但我无法看到/点击其中的按钮.该按钮具有UIA_loginview_loginbutton的辅助功能标签,并且启用了辅助功能.为什么它没有显示在logElementTree()上?
var target = UIATarget.localTarget();
var application = target.frontMostApp();
var window = application.mainWindow();
var view = window.elements().firstWithName("UIA_loginview_view");
UIATarget.localTarget().logElementTree();
UIATarget.localTarget().frontMostApp().logElementTree();
if(view == null || view.toString() == "[object UIAElementNil]")
{
UIALogger.logFail("View not found - "+view.toString());
}
else
{
UIALogger.logPass("View found - "+view.toString());
UIALogger.logMessage("View Elements length - "+view.buttons().length);
view.buttons()["UIA_loginview_loginbutton"].tap();
}
Run Code Online (Sandbox Code Playgroud)
日志元素树://显示我的视图,但不显示其中的按钮
4)UIAElement [name:UIA_loginview_view value:(null)NSRect:{{0,20},{320,460}}]
我创建了一个简单的项目,使用的故事板只包含一个模式=日期的UIDatePicker(因此日期显示为"11月""28""2011").
在仪器UI自动化中我试图设置各个日期选择器轮的值.
我可以成功使用selectValue()方法来设置包含数值的轮子,但无法设置月份的文本值,例如"十一月".
这有效..
target.frontMostApp().mainWindow().pickers()[0].wheels()[1].selectValue(12);
Run Code Online (Sandbox Code Playgroud)
但这不..
target.frontMostApp().mainWindow().pickers()[0].wheels()[0].selectValue("November");
Run Code Online (Sandbox Code Playgroud)
我收到错误: Script threw an uncaught JavaScript error: - selectValue is not supported on a picker with undefined values
我做了一个UIATarget.localTarget().frontMostApp().logElementTree(),可以看到价值是正确的:
UIAPickerWheel:value:November rect:{{1,142},{146,216}}
请允许任何人提出我可能做错的建议,非常感谢.
我有一个iOS5 iPad应用程序使用CLLocationManager我正在测试UIAutomation.
在运行我的测试脚本之前,我在使用CLLocationManager时在iOS上显示的对话框上手动按"确定".
有时,我的测试脚本将无法启动.我按下"播放"图标Instruments,12秒内没有任何反应.然后,我得到以下异常:
Target app is not frontmost
Run Code Online (Sandbox Code Playgroud)
一旦发生这种情况,我通常必须重新启动以使仪器再次工作.
当我CLLocationManager在应用程序前面离开对话框时,我曾经遇到同样的异常.有没有人知道如何解决这个问题?
instruments cllocationmanager ios ios-simulator ios-ui-automation
我正在尝试自动化测试具有 CA 层对象的应用程序的测试。Apple 提供的 UI 自动化框架不识别 CA 层对象。我想要一个帮助识别 CA 层对象的 ui 自动化工具列表。我可以得到工具列表吗?
我正在尝试使用xcode 4.5中的自动化编写测试脚本.
我有一个UICollectionView,我想点击一些当前不可见的单元格.
根据文档,我应该cells返回集合视图中的所有单元格,并visibleCells仅返回当前可见的单元格.
相反,我所看到的是,单元格只返回当前可见的单元格,调用visibleCells会停止脚本 'undefined' is not a function (evaluating 'collection.visibleCells()')
var target = UIATarget.localTarget();
var collection = target.frontMostApp().mainWindow().collectionViews()[0];
UIALogger.logMessage("Looking in collection: " + collection);
UIALogger.logMessage("Cells: " + collection.cells() + " length " + collection.cells().length);
UIALogger.logMessage("Visible cells: " + collection.visibleCells());
Run Code Online (Sandbox Code Playgroud)
上面的代码返回正确的UICollectionView第二个日志行打印:
Cells: [object UIAElementArray] length 12
Run Code Online (Sandbox Code Playgroud)
虽然我在集合视图中有100个项目,但第三个日志行崩溃了脚本.
这是一个文档/ UIACollectionView错误吗?
任何想法如何告诉自动化滚动,直到它看到一个名为"我的手机"的单元格?我已经尝试过使用someCell.scrollToVisible,但是我需要让单元格来做这件事,而我不会因为我无法从单元格中获取它.
编辑:
正如Jonathan所建议的那样,我实现了一个滚动查找函数.这是一个特定的实现,所以你可能需要调整isCellWithName.我也想添加一个休息时间,以防我们在while循环中找不到所需的单元格,如果有人有想法,请随时编辑它.
function isCellWithName(cell, name) {
return (cell.staticTexts()[0].name() == name);
}
function getCellWithName(array, name) …Run Code Online (Sandbox Code Playgroud) 每当我尝试通过Apple在Instruments(iPhone模拟器)中进行UI自动化时,我都会运行几个不同的脚本.问题是,当前一个脚本结束时,我需要坐下来运行每个脚本.我想知道如果仍然需要坐下来运行每个脚本,那么自动化的用途是什么.
任何人都可以告诉我(或者有没有)只需点击一下就能运行多个脚本的方法?并且不需要为每个脚本运行记录按钮?
automated-tests instruments ui-automation xcode-instruments ios-ui-automation
我正在尝试从jenkins运行UI Automation脚本:
instruments -w 'iPhone 6 (8.1 Simulator)' \
-t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
'myAppName' \
-e UIASCRIPT 'some_path' \
-e UIARESULTSPATH 'some_other_path'
Run Code Online (Sandbox Code Playgroud)
但我收到错误,模拟器无法启动
Waiting for device to boot...
2015-03-18 10:29:04.064 instruments[13082:64124] [MT] iPhoneSimulator: Could not launch simulator: -10810
Run Code Online (Sandbox Code Playgroud)
我从jenkins用户下的命令行运行时工作.
非常感谢任何帮助,谢谢.
我有一个简单的函数,应该检查视图是否在home接口,如果没有,将它带到家里:
function returnHome() {
if (UIATarget.localTarget().frontMostApp().navigationBar().name() == mainTitle) return true;
// set tab bar to calculations
UIALogger.logMessage("Set tab bar to main.");
if (UIATarget.localTarget().frontMostApp().tabBar().selectedButton().name() != mainTabName) {
UIATarget.localTarget().frontMostApp().tabBar().buttons()[mainTabName].tap();
}
// go back to the home
UIALogger.logMessage("Go back to home.");
var backButton = UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Back"];
if (backButton.isValid()) {
backButton.tap();
} else {
UIALogger.logError("Could not find 'Back' button!");
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我无法通过错误"无法找到'返回'按钮!".它在那里,在左角,盯着我,嘲弄我!
在UIATarget.localTarget().frontMostApp().logElementTree()给了我下面的树:
2) UIAApplication [name:MyApplication value:(null) rect:{{x:0, y:20}, {width:320, height:460}}]
3) UIAWindow [name:(null) value:(null) rect:{{x:0, y:0}, {width:320, height:480}}]
4) UIAImage [name:(null) value:(null) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用frank(反过来UISpec)为我们的新iOS应用程序编写一些验收测试.虽然框架支持触摸作为与视图交互的基本方式,但它目前不支持任何更多涉及的手势(例如,捏合,滑动等).我需要添加对滑动的支持,至少因为这是我们应用程序功能的核心,没有它我们的测试将毫无用处.
如果我能找到一种模拟Cocoa事件的方法,那么实现它应该相当简单.如果您使用Apple的UIAutomation框架(请参阅此处),则可以发送滑动手势,因此这是一个在外部生成这些事件的示例.我在网上搜索过,但没有找到任何人这样做的例子(虽然有一个帖子,有人在此之前要求类似的东西......).
非常感谢您的帮助/想法......
我正在写一个UIAutomation测试用例,我需要等待用户激活才能继续.似乎没有一种很好的方法可以检查按钮是否可以更改为启用状态.
什么是最好的是在检查它的状态之前等待UI中发生的事情?
dispatch_after和NSTimer似乎都不起作用.他们只是阻止失败.
ios ×8
instruments ×3
iphone ×2
calayer ×1
cocoa-touch ×1
gesture ×1
jenkins ×1
object ×1
uiscrollview ×1
uispec ×1
xcode ×1
xcode7 ×1
xctest ×1