标签: xcode-ui-testing

如何在XCUIElementQuery中获取XCUIElement的索引?

这是我的简单UITest (tabbarcontroller中的标签的自定义顺序):

func testIsOrderOfTabsSaved() {

    let app = XCUIApplication()
    let tabBarsQuery = app.tabBars
    tabBarsQuery.buttons["More"].tap()
    app.navigationBars["More"].buttons["Edit"].tap()
    tabBarsQuery.buttons["Takeaway"].swipeLeft()
    tabBarsQuery.buttons["In Restaurant"].swipeLeft()

    //here, how to get position of moved button with text "In Restaurant"?
Run Code Online (Sandbox Code Playgroud)

注意:

可以XCUIElement从XCUIElementQuery索引获得.我可以这样做吗?

xcode ui-testing ios swift xcode-ui-testing

5
推荐指数
2
解决办法
9434
查看次数

XCode 7 UITest导出日志

我正在使用XCode7-UItest来测试我的应用程序.

我在UITestTarget的文件中添加了几个日志.这些测试将通过我的构建机器的Xcode在设备上执行.我可以在"显示报告导航器"选项下查看Xcode上的这些日志,但我想将这些日志从构建机器发送给其他开发人员,以便他们可以查看这些日志.

有没有办法通过Xcode收集和导出这些UITest日志?我只能通过手动从XCode粘贴日志来找到这样做,这是一个繁琐的过程.

xcode ui-testing ios xctest xcode-ui-testing

5
推荐指数
1
解决办法
1655
查看次数

如何使用XCUIElementsQuery测试UIView的存在?

很难从Apple找到适用于UI测试框架的文档.我已经看到很多可以找到具有特定名称的按钮和标签的例子,但我怎样才能找到通用的UIViews?

例如,假设我使用accessibilityLabel =="Some View"设置视图,如何在测试执行期间找到具有该名称的视图?

我试过(不成功)以下代码:

XCUIElement *pvc = [[app childrenMatchingType:XCUIElementTypeAny] elementMatchingPredicate:[NSPredicate predicateWithFormat:@"accessibilityLabel == 'Places View'"]];

NSPredicate *exists = [NSPredicate predicateWithFormat:@"exists == true"];
[self expectationForPredicate:exists evaluatedWithObject:pvc handler:nil];
[self waitForExpectationsWithTimeout:10 handler:nil];

NSLog(@"%@", [[app childrenMatchingType:XCUIElementTypeAny] elementMatchingPredicate:[NSPredicate predicateWithFormat:@"accessibilityLabel == 'Places View Controller'"]]);
Run Code Online (Sandbox Code Playgroud)

objective-c xcode-ui-testing

5
推荐指数
1
解决办法
1869
查看次数

Cocoapods将同一个Pod安装到多个目标(带有UITest目标的问题)

我使用此示例为不同的目标安装相同的Pod

从此示例博客文章引用:

http://natashatherobot.com/cocoapods-installing-same-pod-multiple-targets/

# Podfile

platform :ios, '8.0'
source 'https://github.com/CocoaPods/Specs.git'

link_with ['YourProject']

workspace 'YourProject.xcworkspace'
xcodeproj 'YourProject.xcodeproj'

def shared_pods

    #shared pods

end

def testing_pods

    #shared testing pods

end

target 'YourProject' do
    shared_pods
end

target 'YourProjectTests' do
    shared_pods
    testing_pods
end

target 'YourProjectUITests' do
    shared_pods
    testing_pods
end
Run Code Online (Sandbox Code Playgroud)

但是我最终在YourProjectUITests目标中链接了问题:

Undefined symbols for architecture x86_64:

  "_OBJC_CLASS_$_GAI", referenced from:
      objc-class-ref in Utility.o
  "_OBJC_CLASS_$_GAIDictionaryBuilder", referenced from:
      objc-class-ref in HomeViewController.o

  "_OBJC_CLASS_$_NewRelicAgent", referenced from:
      objc-class-ref in AppDelegate.o
  "_kGAIHitType", referenced from:
Run Code Online (Sandbox Code Playgroud)

使用可可豆荚0.39.0&Xcode 7.2

我将尝试删除pod.lock并重新安装pod ..

当我在pod配置中删除UITestTarget时,我不再有任何冲突

xcode ios cocoapods xcode-ui-testing

5
推荐指数
0
解决办法
478
查看次数

等待所有HTTP请求在XCode UI测试中完成?

在XCode中测试UI时是否有办法等待所有网络请求完成?

我有一个应用程序发送HTTP请求以从服务器获取一些数据,并且在UI测试中,我想等待在继续之前检索这些数据.目前我正在使用,sleep(1)但这种方法似乎不可靠.

xcode ui-testing ios swift xcode-ui-testing

5
推荐指数
1
解决办法
1028
查看次数

DOMException 105仅在UI测试期间

我间歇性地得到一个未处理的DOMException 105.它只在运行我的UI测试时发生.

如果我注释掉使用loadHTMLString:baseURLcall UIWebView,那么异常就不再发生了.

这使我的测试非常不可靠.关于如何解决这个问题的任何建议?

堆栈跟踪:

2017-01-05 16:57:01.431 Allhomes[64245:4871703] *** Terminating app due to uncaught exception 'DOMException', reason: '*** DOMException 105'
*** First throw call stack:
(

0   CoreFoundation                      0x0000000110e4dd4b __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x00000001104b721e objc_exception_throw + 48
2   CoreFoundation                      0x0000000110e4dc99 -[NSException raise] + 9
3   WebCore                             0x000000011785a542 _ZN7WebCore17raiseDOMExceptionEi + 370
4   WebCore                             0x000000011785a55e _ZN7WebCore23raiseTypeErrorExceptionEv + 14
5   WebCore                             0x00000001177e311e -[DOMRange setStart:offset:] + 158
6   UIKit                               0x000000010d92edab -[UIWebDocumentView text] + 292
7   UIKit                               0x000000010d6afcde _UIViewDescriptionAppendTextIfApplicable + …
Run Code Online (Sandbox Code Playgroud)

objective-c uiwebview ios xcode-ui-testing

5
推荐指数
1
解决办法
995
查看次数

如何编写使用推送通知有效负载启动应用程序的UI测试,并验证您是否已路由到正确的视图?

我正在iOS应用程序中实现推送通知,正如我所做的那样,我想编写一个UI测试,用于验证应用程序在使用某个推送通知负载启动时是否正确(即应用程序导航)到正确的表视图并突出显示正确的单元格).

可以这样做吗?我似乎无法找到之前已经做过此事或曾经问过这个问题的人.

感谢任何指针.

push-notification ios swift xcode-ui-testing

5
推荐指数
1
解决办法
1611
查看次数

在Xcode ui测试Swift中查找表格单元格

我是Xcode + ios测试的新手.我将在swift中自动化现有ios项目的ui.问题是我无法找到视图的表视图.这是我用于从表视图中查找单元格的代码,但在这种情况下这不起作用:

XCUIApplication().tables.cells.allElementsBoundByIndex[1].tap()
Run Code Online (Sandbox Code Playgroud)

我正在附加视图流的截图.ios代码不是我写的.在我的ui测试中我需要找到的事件表视图

xcode objective-c ios swift xcode-ui-testing

5
推荐指数
1
解决办法
5232
查看次数

无法确定可命中的tableViewCell的屏幕点

要对我的应用进行UI测试,我必须启用/禁用iCloud.我通过在测试中启动"设置"应用程序,导航到Apple ID场景,然后点击iCloud单元格(参见下图)来完成此操作.

在此输入图像描述

在我的测试中,我检查iCloud单元是否存在并且是可命中的.然后我点击单元格:

// when
let iCloudCell = settingsApp.tables.cells["iCloud"]
let iCloudCellFound = iCloudCell.waitForExistence(timeout: 10)
// then
XCTAssert(iCloudCellFound, "iCloud settings not found")
XCTAssert(iCloudCell.isHittable, "iCloud settings not hittable")

// when
iCloudCell.tap()
Run Code Online (Sandbox Code Playgroud)

这在大多数情况下都有效,但是现在测试在iCloudCell.tap()日志中 停止

t =   113.74s         Find: Descendants matching type Table
t =   113.74s         Find: Descendants matching type Cell
t =   113.74s         Find: Elements matching predicate '"iCloud" IN identifiers'
t =   113.85s     Synthesize event
t =   113.97s         Assertion Failure: <unknown>:0: Failed to determine screen point of …
Run Code Online (Sandbox Code Playgroud)

xcode ui-testing uitableview ios xcode-ui-testing

5
推荐指数
0
解决办法
580
查看次数

有人知道Xcode 11 UI测试的测试结果如何吗?

我曾经能够访问.xcresults包中的“派生数据”中的结果。.xcresults包仍然存在,但是以前曾经有一个名为“ TestSummaries.plist”的文件以及包含附件的子目录(例如屏幕快照文件等),现在有一个名为“ Data”的子目录,其中包含二进制格式的文件。因此,现在我不再能够以编程方式提取屏幕快照文件,也无法将测试结果上传到qTest或ALM等数据库。

我已经确认Xcode 10仍以旧格式输出结果。我已经在计算机上搜索“ TestSummaries.plist”文件或类似的工件,以为它们可能位于其他位置。到目前为止没有运气。

xcode-ui-testing xcode11

5
推荐指数
2
解决办法
210
查看次数