【问题标题】:xcode ui testing Recoding fails to generate codexcode ui testing Recoding 生成代码失败
【发布时间】:2021-07-24 15:25:45
【问题描述】:

我创建了一个新的 iOS SwiftUI 应用并添加了以下 ContenView

struct ContentView: View {
    var body: some View {
        VStack {
            Text("Hello, world!")
                .padding()
            Button("Press Me", action: {
                return print("button pressed")
            })
        }
    }
}

我尝试添加一个 UI 测试,在其中检查按钮是否被按下。

无论我做什么,在测试中按下录制按钮后,测试函数中都不会生成任何代码。

此时每个示例都没有问题。

录制按钮没有变灰显示。

我错过了什么想法?

【问题讨论】:

  • return 语句不属于Buttonaction 中删除它,您应该会在控制台中看到"button pressed" 语句
  • 尝试将可访问性标识符附加到您感兴趣的元素。

标签: ios xcode ios-simulator xcode-ui-testing xcode12.5


【解决方案1】:

在 Xcode 12.5.1 中修复,代码生成再次工作;)

【讨论】:

    【解决方案2】:

    UI 测试录制在 Xcode 12.5 中不起作用,请尝试安装 12.4。它仍然在那里工作。

    【讨论】:

      猜你喜欢
      • 2016-10-28
      • 2015-11-20
      • 1970-01-01
      • 2016-12-18
      • 2015-04-15
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多