How to add an image for multiple locales using XCTest

An annoying thing I’ve had to deal with recently is adding an image (both where you take a photo with the camera and also from the gallery).

You might think that sounds pretty straight forward, but when you want to run your test in multiple locales then “Choose from library” and “Upload photo” etc just doesn’t quite cut it.

Attempts to record the steps I took within the gallery view also proved futile, as I could not actually record what I did there.

Not sure why I didn’t opt for waitForExpectation, and used a sleep though.

Here is how I went about adding images to my tests:

 func testAddPhoto() {
    let addPhotoButton = app.tabBars
    let photoLibraryButton = app
    let takePhotoButton = app


    XCTAssertEqual(waiterResultWithExpectation(photoLibraryButton), .completed)


    //here I am selecting the first image album

    //opted for a sleep to give it time for the images to appear

    //selecting the most recent image