Fastlane claims to take screenshots for me for all screen sizes and localizations.
According to the guide, I created a UI test case like this:
override func setUp() {
super.setUp()
continueAfterFailure = false
setupSnapshot(XCUIApplication())
XCUIApplication().launch()
}
override func tearDown() {
super.tearDown()
}
func testExample() {
let app = XCUIApplication()
app.collectionViews.staticTexts["13"].swipeRight()
snapshot("calendar")
let staticText = app.collectionViews.staticTexts["26"]
staticText.tap()
snapshot("preview")
app.buttons["Editor"].tap()
snapshot("editor")
app.navigationBars["2016/6/26"].buttons["Cancel"].tap()
app.navigationBars["My Diaries"].buttons["search filled"].tap()
let tablesQuery = app.tables
tablesQuery.textFields["Search"].tap()
tablesQuery.textFields["Search"].typeText("beach")
snapshot("search")
app.navigationBars["Search"].buttons["search colored"].tap()
app.navigationBars["Results - 1 / 2"].buttons["right"].tap()
snapshot("result")
}
When I run the test in an English Simulator, it succeeds. When I run the test in a Chinese Simulator (I localized my app to Chinese. That's why I want to run it in Chinese), the test doesn't work because it can't find those English words in my app.
But from the guide, I would imagine it would handle this for me, using NSLocalizedString
or something like that.
So I cd
to the project directory, snapshot
, then chose a target and it starts taking screenshots...
... until it reaches the part where it should tap on the "Editor" button, because it couldn't find the English word. And it crashed.
So do I need to add if statements to check which localization is the app in? That would be a pain in the neck to do! I'd rather take screenshots myself if that's the case.
I think I must be misunderstanding fastlane. What is the correct way of taking screenshots using Snapshot?