4

I want to create screenshots using fastlane snapshot. I am facing problems in three different cases.

Case 1: I have a collection view that has cells with one image and a label. Tapping on a cell will open a VC (lets call it editVC) that is a form used for editing the item tapped from collection view. editVC is embedded in a navigation controller.

Recorded test is as below

func testOne() {

    let app = XCUIApplication()
    app.tabBars.buttons["Collection View"].tap()
    app.children(matching: .window).element(boundBy: 0).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .collectionView).element.tap()
        snapshot("01")


}

The test runs successfully from xcode.

Issue is when i run "fastlane snapshot" from terminal, screenshot generated is for collection view and not the editVC.

Case 2: A view controller (call it homeVC) that has a scroll view that contain multiple collection views that scroll horizontally. The collection view in question also has cells with one image and a label. Tapping on cell will open a view controller (vc2) that will display items details. This vc2 is embedded in a navigation controller and called using storyBoard.instantiateViewController() and present() methods.

Below is test recorded tap to vc2. This test runs fine but "fastlane snapshot" doesn't generate screenshot for VC2. it generates for homeVC.

func testVC2() {

    let app = XCUIApplication()
    app.tabBars.buttons["Home"].tap()

    let scrollViewsQuery = app.scrollViews
    scrollViewsQuery.otherElements.containing(.staticText, identifier:"label").children(matching: .collectionView).element(boundBy: 1).tap()
    snapshot("vc2")
}

I tried adding waitForExpectations(timeout: 10, handler: nil) using expectation() but even after 10 seconds, the transition doesn't seem to happen to vc2.

Case 3: A Vc has a table view that has cells with image and label. The UI test recorded for tapping from table cell and opening another VC that has a collection view is as below and fails with error No matches found for Find: Descendants matching type ScrollView from input

func test123() {
    XCUIApplication().tabBars.buttons["tab1"].tap()

    let app = XCUIApplication()
    let scrollViewsQuery = app.scrollViews
    scrollViewsQuery.otherElements.containing(.staticText, identifier:"cellitem").children(matching: .collectionView).element(boundBy: 1).tap()


}

What could be the reason for these cases? Hope i am able to explain the setup clearly.

Environment - xcode 9.0

Thanks Ashish

ashishn
  • 410
  • 5
  • 18

0 Answers0