标签: xcode-ui-testing

XCUIElement 是否有类似的 WebElement getText()

我正在使用XCUITest使用Xcode 7.3进行AppleTV UI 测试。

它有XCUIElement同样的喜欢WebElement但是Selenium WebElement中是否存在类似的getText()方法。XCUIElement

基本上我想从XCUIElement.

例如:

let ele:XCUIElement = XCUIApplication().collectionViews.cells[
                                               "Sign In to Activate"].
Run Code Online (Sandbox Code Playgroud)

那么是否可以从元素中获取值: “登录以激活” 。有帮助吗?

selenium xcode-ui-testing

0
推荐指数
1
解决办法
2892
查看次数

在 xcode ui test 中运行所有测试类

我对 xcode ui 应用程序测试完全陌生。我有 ios 应用程序的源代码。但我必须使用 xcode ui test 来测试应用程序。目前我正在通过创建新文件并通过记录添加测试用例来向我的 ui 测试添加新的测试类。

我可以单独运行我的测试类。但我想一次执行我所有的测试类。我怎么能做到这一点。

我是这个领域的新手。任何形式的帮助将不胜感激。

你也可以给我一个 ui 测试项目链接或任何可以帮助我的链接。我浏览了 apple.developers 网站。

xcode ios swift xcode-ui-testing xcode7.3

0
推荐指数
2
解决办法
4613
查看次数

如何使UIControl在XCUITest中显示为按钮?

我创建了UIControl的子类,该子类的行为应类似于UIButton。

当我使用XCUITest运行UI测试时,出现的按钮XCUIApplication().staticTexts不是预期的XCUIApplication().buttons

ios xcode-ui-testing

0
推荐指数
1
解决办法
455
查看次数

Swift XCUI字符串断言失败

我正在使用xcode 8.3.3并编写XCUI测试.

我有以下内容: let address = XCUIApplication().buttons["URL"].value as! String

查看调试器,我可以看到值是:

在此输入图像描述

如果我设置 expectedURL = "\u{e2}auth.int....net"然后它返回:在此输入图像描述

如果我设置 expectedURL = "auth.int....net"然后它返回:在此输入图像描述

如何使测试断言找到两个相等的字符串?

试过以下内容,但它不会取代"\ u {e2}":

let address = value.components(separatedBy: ",").first!.replacingOccurrences(of: "\u{e2}", with: "")
Run Code Online (Sandbox Code Playgroud)

而且(但它不会取代"\ u {e2}"):

let range = Range<String.Index>(uncheckedBounds: (lower: address.startIndex, upper: address.endIndex))

let strippedAddress = address.replacingOccurrences(of:"\\u{e2}", with: "", options: .literal, range: range)
Run Code Online (Sandbox Code Playgroud)

对于断言,我正在使用 XCTAssertEqual(address, expectedURL)

xcode ios ios-ui-automation swift xcode-ui-testing

0
推荐指数
1
解决办法
341
查看次数

XCTest 无法访问屏幕上的错误消息标签

背景资料:

\n

我需要为简单的应用程序屏幕编写一些 UI 测试,该屏幕顶部有一个导航栏,屏幕其余部分有一个包含两个单元格的表格。

\n

每个单元格包含:

\n
    \n
  • 标签(“会员卡号”)
  • \n
  • 用于输入的安全文本字段
  • \n
  • 安全字段下的标签(“您必须在此处放置\n10 位会员卡号”)
  • \n
  • 仅当用户输入的位数少于或多于所需位数时,才会在输入字段下显示可选的错误文本
  • \n
\n

这是一张图像,可让您了解屏幕上的元素\n图像

\n

目标:

\n

编写一个测试执行以下操作:

\n
    \n
  • 点击卡片输入字段
  • \n
  • 输入无效的卡号(假设是 12 位数字而不是 10 位)
  • \n
  • 检查该字段下是否出现错误消息
  • \n
\n

问题:

\n

XCTest 无法识别包含错误的元素。

\n

当我使用调试视图层次结构检查元素时,它就在那里,清晰可见,文本属性“不能少于或超过 10 位数字”,accessibiltyIndentifier“errorField”。

\n

层次结构: UIWindow->UILayoutContainerView->UINavigationTransitionView->UIViewControllerWrapperView->UIView->Form->FormTextFieldCell->UITableViewCellContentView->UIView->UILabel

\n

它有一个同级,也是 UILabel(“这是您必须放置 10 位会员卡的地方”) - 访问这个同级没有问题。我可以通过accessibilityIdentifier或其文本访问它:

\n
app.staticTexts["hintField"]\napp.staticTexts["This is where you must put your 10-digit loyalty card"]\n
Run Code Online (Sandbox Code Playgroud)\n

但这些选项都不适用于我感兴趣的元素。当我打印 app.debugDescription 时,该元素不存在,就好像它不存在一样。

\n

以下是用户输入错误并且错误文本已在屏幕上可见后 debugDescription 的输出:

\n
Element subtree:\n \xe2\x86\x92Application 0x60000016e700: {{0.0, …
Run Code Online (Sandbox Code Playgroud)

ios xctest xcode-ui-testing xcode8

0
推荐指数
1
解决办法
2888
查看次数

UItesting : 点击 UIcollectionview 然后测试它失败

我是 ui-testing 的新手。在记录期间,当我挖掘UI收集查看第一对象被显示在用户界面和对应于写入在测试示例方法的代码是:

XCUIElement *window = [[app childrenMatchingType:XCUIElementTypeWindow] elementBoundByIndex:0];
    XCUIElement *element2 = [[[[window childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element;
    [element2 tap]; 
Run Code Online (Sandbox Code Playgroud)

并且在自动化 test-example 方法时,无法获取 ui-collection view 的第一个对象。请建议一种方法来做到这一点。提前致谢。

xcode objective-c ios uicollectionview xcode-ui-testing

0
推荐指数
1
解决办法
2980
查看次数

使用arc4random生成随机数以添加到字符串以进行UI测试登录xcode UI测试

我正在测试注册应用程序,使用xcode UI测试我想知道如何使用arc4random生成一个随机数,将被输入到应用程序?

这是我的代码,但得到一个类型canont将类型为UInt32的值转换为预期的参数类型字符串.

 let emailBox = self.app.textFields["Email"]
    if emailBox.exists {enter code here
        emailBox.tap()
        emailBox.typeText("testing" + arc4random() + "gmail.com")
    }
Run Code Online (Sandbox Code Playgroud)

testing xcode arc4random ios xcode-ui-testing

-1
推荐指数
1
解决办法
274
查看次数