相关疑难解决方法(0)

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
查看次数

标签 统计

ios ×1

ios-ui-automation ×1

swift ×1

xcode ×1

xcode-ui-testing ×1