相关疑难解决方法(0)

有没有办法在Swift XCTest UI中的测试之间重置应用程序?

我是否可以在XCTest中调用API调用setUP()或tearDown()以在测试之间重置应用程序?我查看了XCUIApplication的点语法,我看到的只是.launch()

或者有没有办法在Swift中调用shell脚本?然后我可以调用xcrun中间的测试方法来重置模拟器.

xctest swift xcode7 xcode-ui-testing

65
推荐指数
11
解决办法
3万
查看次数

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

我正在使用Xcode7/iOS 9中引入的XCUIApplication,XCUIElement和XCUIElementQuery为我的应用程序编写UI测试用例.

我遇到了路障.测试用例中的一个屏幕需要iOS的位置服务.正如预期的那样,系统会提示用户允许使用名为" Allow “App name” to access your location while you use the app?with Allow&Don't Allowbuttons"的警报来使用位置服务.

问题是或许似乎由于警报由OS本身呈现,因此它不存在于Application的元素子树中.

我记录了以下内容:

print("XYZ:\(app.alerts.count)")//0
var existence = app.staticTexts["Allow “App Name” to access your location while you use the app?"].exists
print("XYZ:\(existence)")//false
existence  = app.buttons["Allow"].exists
print("XYZ:\(existence)") //false
Run Code Online (Sandbox Code Playgroud)

甚至UI录制生成类似的代码:

XCUIApplication().alerts["Allow “App Name” to access your location while you use the app?"].collectionViews.buttons["Allow"].tap()
Run Code Online (Sandbox Code Playgroud)

我还没有找到任何可以让我解决这个问题的API.例如:

  • 点按屏幕上的某个位置
  • 在应用外部获取提醒

那我该怎么办呢?有没有办法配置测试目标,以便不需要位置服务授权.

xcode xctest ios9 xcode-ui-testing xcode7-beta4

31
推荐指数
2
解决办法
1万
查看次数

标签 统计

xcode-ui-testing ×2

xctest ×2

ios9 ×1

swift ×1

xcode ×1

xcode7 ×1

xcode7-beta4 ×1