我遇到的问题是使用Alamofirexcode UI 测试。
我已尽可能地将各个部分隔离开来,试图找出问题可能出在哪里,但仍然无法解决这个问题。通过使用 swift 的新 xcode 项目,我可以Alamofire按预期使用 mainViewController.swift和func viewDidLoad()函数,但是在创建 UI 测试时,我无法在函数中使用相同的代码func testExample()。
使用的工具版本:
\n\nXcode = 9.2(9C40b) \nSwift = 4.0\ncocoapods = 1.4.0 \nmacOS = High Sierra Version 10.13.2 (17C205) \nAlamofire = 4.5 \nRun Code Online (Sandbox Code Playgroud)\n\nViewController.swift - 工作正常
\n\nimport UIKit\nimport Alamofire\n\nclass ViewController: UIViewController {\n\n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view, typically from a nib.\n\n Alamofire.request("https://httpbin.org/get").responseJSON { response in\n print("Request: …Run Code Online (Sandbox Code Playgroud) 我的应用程序有 UITests,并且所有测试都运行良好,但有时在执行几个测试后,其他测试开始失败,因为60.0 秒后无法终止 com.test.abc:3708; 状态依然是Running Foreground(4)CreateUserUITest
我们有一个 iOS 应用程序,并为其编写了 XCUI 测试。我们需要在测试运行时调试 iOS 应用程序以捕获一些数据。但应用程序中设置的断点永远不会被命中。只有测试目标中的断点才会被命中。在 ui 测试运行时是否无法调试应用程序?有什么解决办法吗?
谢谢,瑞诗玛
我已经开始并行运行我的用户界面测试,以提高性能。但是,当使用 xcpretty 时,我现在不知道哪些测试已经通过,也不知道是什么导致测试失败(我只知道哪些测试失败了)。有什么办法可以解决这个问题吗?或者是 xcpretty 的替代方案,可以处理并行测试中的输出。我希望有一个很好的终端输出,就像使用顺序测试时一样。
\n\n这是我的脚本:
\n\n xcodebuild \\\n -workspace \'./code/ios/myApp/myApp.workspace\' \\\n -scheme \'myApp\' \\\n -destination \'platform=iOS Simulator,name=iPhone 6\' \\\n test | xcpretty -c \nRun Code Online (Sandbox Code Playgroud)\n\n这是我按顺序运行测试时得到的输出(以及我想在并行运行它们时继续获得的输出):
\n\nSelected tests\n\n[15:35:45]: \xe2\x96\xb8 Test Suite UITests.xctest started\n\n[15:35:45]: \xe2\x96\xb8 RegisterTest\n\n[15:36:48]: \xe2\x96\xb8 \xe2\x9c\x97 testRegisterBrazil, failed - Couldn\'t find: \n"homeBottomBar_myAccountButton" Button\n\n[15:42:50]: \xe2\x96\xb8 \xe2\x9c\x93 testRegisterUSA (61.241 seconds)\n\n[15:42:50]: \xe2\x96\xb8 Executed 4 tests, with 1 failures (1 unexpected) in 425.314 (425.319) seconds\nRun Code Online (Sandbox Code Playgroud)\n\n这是我现在得到的输出:
\n\nFailing tests:\n\n UITests:\n\n RegisterTest.testRegisterBrazil()\n** TEST FAILED **\nRun Code Online (Sandbox Code Playgroud)\n 我正在迁移以使用新的 Xcode 12,但我在 UI 测试方面遇到问题。代码
let springBoard = XCUIApplication(bundleIdentifier: appleBundleIdentifier) let notification = springBoard.otherElements["NotificationShortLookView"]
不再工作,我找不到如何指示通知视图。是如何改变的?
我正在尝试为我的控制器创建UI测试。我填充了文本字段并点击了按钮,现在我想等待对话框出现,当对话框停止时,我想点击确定按钮并检查显示的控制器。
这是我的测试方法的结尾:
let alert = app.alerts["Error"]
let exists = NSPredicate(format: "exists == 1")
self.expectationForPredicate(exists, evaluatedWithObject: alert, handler: nil)
self.waitForExpectationsWithTimeout(5.0) { (error) in
XCTAssertNil(error, "Something went horribly wrong")
alert.buttons["Ok"].tap()
XCTAssertEqual(app.navigationBars.element.identifier, "RegistrationViewController")
}
Run Code Online (Sandbox Code Playgroud)
问题是测试被评估为失败,但是当我看着电话时,出现对话框,点击确定按钮,控制器也很好。
我在调试窗口中遇到此故障:
UI测试失败-未找到与警报匹配的内容
我想那把Tap有某种问题。我该如何解决?我做错了什么?谢谢
我已经读完了这两个.
Xcode7 | Xcode UI测试| 如何处理位置服务警报?
我能知道以下情况吗?
1)对于位置,放置"位置对话框"表示它将处理位置提示.它如何识别?
2)如何处理访问图库或相机的系统提示?是否有任何处理程序描述列表?
我正在尝试解除我正在使用的XCUITest套件上的警报
app.alerts.buttons["OK"].tap()
Run Code Online (Sandbox Code Playgroud)
使用此功能会解除警报,但随后应用程序继续尝试点击按钮然后失败并显示错误消息" UI TESTING FAILURE-找不到匹配的警报 "
这是控制台输出
t = 0.00s Start Test at 2016-11-03 14:07:30.827
t = 0.00s Set Up
t = 0.00s Launch uk.co.myapp
t = 4.89s Waiting for accessibility to load
t = 12.55s Wait for app to idle
t = 18.46s Snapshot accessibility hierarchy for uk.co.myapp
t = 19.24s Find: Descendants matching type Button
t = 19.25s Find: Elements matching predicate '"Enable notifications" IN identifiers'
t = 19.26s Tap "Enable notifications" Button
t = 19.26s Wait …Run Code Online (Sandbox Code Playgroud) 有没有人有类似的情况?因此,应用程序打开,推送通知警报显示询问用户是否允许接收推送通知,测试单击"不允许",即使我有以下代码:
func testClickSystemAlert(){
let app = XCUIApplication();
XCUIApplication().alerts["“???” Would Like to Send You Notifications"].buttons["Allow"].tap()
}
Run Code Online (Sandbox Code Playgroud)
这是print的输出(XCUIApplication().debugDescription);
Attributes: Application 0x60000016c540: {{0.0, 0.0}, {414.0, 736.0}}, label: '???'
Element subtree:
?Application 0x60000016c540: {{0.0, 0.0}, {414.0, 736.0}}, label: '???'
Window 0x60000016bc40: Main Window, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x60000016c780: {{0.0, 0.0}, {414.0, 736.0}}
Other 0x60000016c9c0: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
ScrollView 0x60000016bf40: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Image 0x60000016c0c0: traits: 8589934596, {{0.0, 0.0}, {414.0, 736.0}}, identifier: '1'
PageIndicator 0x600000163000: traits: 8589939200, {{132.0, …Run Code Online (Sandbox Code Playgroud) 我正在从Jenkins构建脚本运行iOS应用程序的AppUITests.单元测试(AppTests)运行正常但AppUITests由于以下问题而失败.我该如何解决这个问题?
09:19:53.506 XCTRunner [22911:77924]无法在30.0秒内进行后台测试跑步.09:19:53.507 xcodebuild [22835:77541] - [IDETestOperationCoordinator testRunnerSession:initializationForUITestingDidFailWithError:] 09:19:53.507 XCTRunner [22911:77924]调用完成.09:19:53.507 xcodebuild [22835:77541]测试操作失败:无法进行后台测试跑步者.09:19:53.507 xcodebuild [22835:77541] _finishWithError:错误Domain = IDETestOperationsObserverErrorDomain Code = 13"无法对后台测试跑步者. "UserInfo = {NSLocalizedDescription =无法进行后台测试跑步者.} didCancel:1
xcode-ui-testing ×10
ios ×7
xcode ×7
swift ×5
alamofire ×1
alert ×1
cocoapods ×1
ios14 ×1
jenkins ×1
ui-testing ×1
xcode10 ×1
xcode12 ×1
xcode7 ×1
xcodebuild ×1