我正在用新的XCode 7做一些UI测试,我的应用程序是如何使用通知的,第一次使用iOS会自动询问‘MyApp’想给你发送通知‘。
当我记录测试时,XCode会在下面写以下几行:
- (void)testFirstUse {
[XCUIDevice sharedDevice].orientation = UIDeviceOrientationPortrait;
XCUIApplication *app = [[XCUIApplication alloc] init];
[app.alerts[@"\U201cMyApp\U201d Would Like to Send You Notifications"].collectionViews.buttons[@"OK"] tap];
[app.tables/*@START_MENU_TOKEN@*/.staticTexts[@"United States"]/*[[".cells.staticTexts[@\"United States\"]",".staticTexts[@\"United States\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ tap];
[app.navigationBars[@"Select a Country"].buttons[@"Next"] tap];
}注意,XCode将unicode而不是引号放在MyApp名称上。当运行时,测试失败,错误为“未找到警报匹配”。
我尝试将unicode更改为引号,但它也不起作用。
清楚了吗?有过同样的问题吗?
更新我在这段代码中有两个问题
1- XCode生成的独角兽消息上有一个bug。
2-系统显示警报后测试失败
发布于 2015-09-25 13:32:56
在取消系统警报之后,我发现了一种避免崩溃的方法:
我换了这条线
[app.alerts[@"\U201cMyApp\U201d Would Like to Send You Notifications"].collectionViews.buttons[@"OK"] tap];至
XCUIElement *alert = app.alerts[@"\U0000201cMyApp\U0000201d Would Like to Send You Notifications"].collectionViews.buttons[@"OK"];
if ([alert exists]) {
[alert tap];
}我做了两个改变
发布于 2015-09-25 12:09:53
您可以通过直接访问alert.element并通过集合视图点击"OK“按钮来确认警报。
let app = XCUIApplication()
app.launch()
// trigger location permission dialog
app.alerts.element.collectionViews.buttons["Allow"].tap()但是,Xcode 7(和Xcode 7.1 Beta)在成功解除警报后将崩溃。我已经打开了一个苹果的bug报告,并鼓励所有遇到问题的人复制它。
发布于 2015-10-01 12:44:58
xcode生成的unicode字符格式是错误的,所以是xcode错误。作为临时的解决办法,您可以替换
[app.alerts[@"\U201cMyApp\U201d Would Like to Send You Notifications"].collectionViews.buttons[@"OK"] tap];使用
[app.alerts[@"\u201cMyApp\u201d Would Like to Send You Notifications"].collectionViews.buttons[@"OK"] tap];即所有\U在\u上
https://stackoverflow.com/questions/32781327
复制相似问题