我正在使用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)
那么是否可以从元素中获取值: “登录以激活” 。有帮助吗?
我对 xcode ui 应用程序测试完全陌生。我有 ios 应用程序的源代码。但我必须使用 xcode ui test 来测试应用程序。目前我正在通过创建新文件并通过记录添加测试用例来向我的 ui 测试添加新的测试类。
我可以单独运行我的测试类。但我想一次执行我所有的测试类。我怎么能做到这一点。
我是这个领域的新手。任何形式的帮助将不胜感激。
你也可以给我一个 ui 测试项目链接或任何可以帮助我的链接。我浏览了 apple.developers 网站。
我创建了UIControl的子类,该子类的行为应类似于UIButton。
当我使用XCUITest运行UI测试时,出现的按钮XCUIApplication().staticTexts不是预期的XCUIApplication().buttons。
我正在使用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)
我需要为简单的应用程序屏幕编写一些 UI 测试,该屏幕顶部有一个导航栏,屏幕其余部分有一个包含两个单元格的表格。
\n每个单元格包含:
\n这是一张图像,可让您了解屏幕上的元素\n
编写一个测试执行以下操作:
\nXCTest 无法识别包含错误的元素。
\n当我使用调试视图层次结构检查元素时,它就在那里,清晰可见,文本属性“不能少于或超过 10 位数字”,accessibiltyIndentifier“errorField”。
\n层次结构: UIWindow->UILayoutContainerView->UINavigationTransitionView->UIViewControllerWrapperView->UIView->Form->FormTextFieldCell->UITableViewCellContentView->UIView->UILabel
\n它有一个同级,也是 UILabel(“这是您必须放置 10 位会员卡的地方”) - 访问这个同级没有问题。我可以通过accessibilityIdentifier或其文本访问它:
\napp.staticTexts["hintField"]\napp.staticTexts["This is where you must put your 10-digit loyalty card"]\nRun Code Online (Sandbox Code Playgroud)\n但这些选项都不适用于我感兴趣的元素。当我打印 app.debugDescription 时,该元素不存在,就好像它不存在一样。
\n以下是用户输入错误并且错误文本已在屏幕上可见后 debugDescription 的输出:
\nElement subtree:\n \xe2\x86\x92Application 0x60000016e700: {{0.0, …Run Code Online (Sandbox Code Playgroud) 我是 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 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) ios ×6
xcode ×4
swift ×2
arc4random ×1
objective-c ×1
selenium ×1
testing ×1
xcode7.3 ×1
xcode8 ×1
xctest ×1