Skip to main content

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.

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


    func testAddPhoto() {

        let addPhotoButton = app.tabBars.buttons[LocalizedString("add.photo.button")].firstMatch

        let photoLibraryButton = app.staticTexts[LocalizedString("photo.library.button")].firstMatch

        let takePhotoButton = app.staticTexts[LocalizedString("take.photo.button")].firstMatch


        addPhotoButton.tap()

        XCTAssertEqual(waiterResultWithExpectation(photoLibraryButton), .completed)

        XCTAssertTrue(photoLibraryButton.isEnabled)

        XCTAssertTrue(takePhotoButton.isEnabled)    

        photoLibraryButton.tap()

        //here I am selecting the first image album

        app.cells.element(boundBy:0).tap()

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

        sleep(1)

        //selecting the most recent image

        app.cells.element(boundBy:0).tap()




  

Comments

Popular posts from this blog

A reflection on Let's Test 2015: Part II

Here's the link to A reflection on Let's Test 2015: Part I The sessions (Part II) Below does not include all of the sessions I went to nor all aspects of the session I mention Visual Creativity: Using Sketchnotes and Mindmaps to aid your agile testing - Dan Ashby and Christina Ohanian Before this session I stumbled upon Christina drawing out her sketch notes from the previous session and marvelled at how fascinating it was. Sketch notes were only something I'd only ever seen on the net. They were gorgeous and a clever way to communicate information. When she told me that she was going to have a session on this - I was all in. We 'warmed up' by drawing whichever image came to mind when Dan said a word. It was interesting to see how a lot of people could interpret the same word differently. For example: "Time" could be a clock, a watch or an hourglass.

Getting started on a testing project

I started on a new project a few weeks ago and thought it would be a good idea to share a checklist for what new testers on a project need and some good starting questions when you, as a tester, are new on a project Checklist for what new testers on a project need (Note, your project may not include all of the below) Note to check if user credentials are needed for any of the below

4 Books Which I've Found Useful for my Testing

 1. Thinking Fast and Slow by Daniel Kahneman I heard from quite a few people how beneficial this book was for them. About six or seven years ago, I tried to read it, but couldn't get into it - then I tried again about two years ago and really enjoyed it. It's an intense read and focuses a lot on cognitive biases - a lot of which I come across in day-to-day testing.  2. Lessons Learned in Software Testing: A Context Driven Approach by Cem Kaner, James Michael Bach and Bret Petticord While this book was written almost 20 years ago, a lot of the lessons still apply today. There's A LOT of useful advice you can apply.  Strongly suggest you get a copy and then use it as a reference when the need arises.  The great thing about this book is that it's split into almost 300 lessons - so you can fairly easily pick it up and put it down. My highlights include: Lesson 9: You will not find all the bugs Lesson 25: All testing is based on models Lesson 57: Make your bug report an e