标签: xcode-ui-testing

无法在 Swift 的 xcode UI 测试中使用 Alamofire

我遇到的问题是使用Alamofirexcode UI 测试。

\n\n

我已尽可能地将各个部分隔离开来,试图找出问题可能出在哪里,但仍然无法解决这个问题。通过使用 swift 的新 xcode 项目,我可以Alamofire按预期使用 mainViewController.swift和func viewDidLoad()函数,但是在创建 UI 测试时,我无法在函数中使用相同的代码func testExample()。

\n\n

使用的工具版本:

\n\n
Xcode     = 9.2(9C40b)    \nSwift     = 4.0\ncocoapods = 1.4.0     \nmacOS     = High Sierra Version 10.13.2 (17C205)  \nAlamofire = 4.5    \n
Run Code Online (Sandbox Code Playgroud)\n\n

ViewController.swift - 工作正常

\n\n
import 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)

xcode cocoapods swift alamofire xcode-ui-testing

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

UITest 60.0s 后无法终止 com.test.abc:3708;状态仍然是“前台运行”

我的应用程序有 UITests,并且所有测试都运行良好,但有时在执行几个测试后,其他测试开始失败,因为60.0 秒后无法终止 com.test.abc:3708; 状态依然是Running Foreground(4)CreateUserUITest

ios swift xcode-ui-testing

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

在 iOS 中运行 UI 测试时如何在应用程序中命中断点?

我们有一个 iOS 应用程序,并为其编写了 XCUI 测试。我们需要在测试运行时调试 iOS 应用程序以捕获一些数据。但应用程序中设置的断点永远不会被命中。只有测试目标中的断点才会被命中。在 ui 测试运行时是否无法调试应用程序?有什么解决办法吗?

谢谢,瑞诗玛

xcode ios swift xcode-ui-testing xcode10

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

并行运行 xcode ui 测试时 Xcpretty 不起作用

我已经开始并行运行我的用户界面测试,以提高性能。但是,当使用 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 \n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我按顺序运行测试时得到的输出(以及我想在并行运行它们时继续获得的输出):

\n\n
Selected 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\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我现在得到的输出:

\n\n
Failing tests:\n\n    UITests:\n\n        RegisterTest.testRegisterBrazil()\n** TEST FAILED **\n
Run Code Online (Sandbox Code Playgroud)\n

xcode continuous-integration xcode-ui-testing

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

如何通过 UI 测试(Xcode 12、iOS14)访问推送通知?

我正在迁移以使用新的 Xcode 12,但我在 UI 测试方面遇到问题。代码

let springBoard = XCUIApplication(bundleIdentifier: appleBundleIdentifier) let notification = springBoard.otherElements["NotificationShortLookView"]

不再工作,我找不到如何指示通知视图。是如何改变的?

ios xcode-ui-testing ios14 xcode12

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

UI测试-等待对话框,然后点击确定按钮并检查控制器

我正在尝试为我的控制器创建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有某种问题。我该如何解决?我做错了什么?谢谢

alert ui-testing ios swift xcode-ui-testing

4
推荐指数
1
解决办法
4843
查看次数

iOS UITesting:使用addUIInterruptionMonitorWithDescription自动处理所有系统提示

我已经读完了这两个.

Xcode7 | Xcode UI测试| 如何处理位置服务警报?

Xcode 7 UI测试:解除推送和位置警报

我能知道以下情况吗?

1)对于位置,放置"位置对话框"表示它将处理位置提示.它如何识别?

2)如何处理访问图库或相机的系统提示?是否有任何处理程序描述列表?

xcode ios xcode-ui-testing

4
推荐指数
1
解决办法
3059
查看次数

解除警报XCUITest

我正在尝试解除我正在使用的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)

xcode swift xcode7 xcode-ui-testing

4
推荐指数
1
解决办法
3691
查看次数

Xcode UITest推送通知警报无法点击"允许"

有没有人有类似的情况?因此,应用程序打开,推送通知警报显示询问用户是否允许接收推送通知,测试单击"不允许",即使我有以下代码:

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)

xcode ios xcode-ui-testing

4
推荐指数
1
解决办法
934
查看次数

iOS UITests失败:IDETestOperationsObserverErrorDomain Code = 13

我正在从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 xcodebuild ios jenkins xcode-ui-testing

4
推荐指数
1
解决办法
1639
查看次数