How can I test the text that SVProgressHud displays?

Viewed 1172

I'm doing UI testing in Swift and the app I'm testing shows many update/progress messages using the pod SVProgressHud. I want to be able to verify whether the correct message is being displayed. How can I capture the SVProgress HUD and get its text?

3 Answers

SVProgressHud is accessibility-ready (at least the version 1.1.3 that I'm using), so it's as simple as:

let message = app.otherElements["Your update/progress message"]

If you're also looking for string localization in UI tests target, please refer to this answer: https://stackoverflow.com/a/44014704/1104337

Show SVProgressHUD with text and setting ring thickness in Swift 4

func startLoader(){

    DispatchQueue.main.async {
        SVProgressHUD.show(withStatus: "Loading...")
        SVProgressHUD.setDefaultStyle(SVProgressHUDStyle.dark)
        SVProgressHUD.setRingThickness(3.0)
        SVProgressHUD.setMinimumDismissTimeInterval(2.0)
    }

}

Thanks!

Hide SVProgressHUD in Swift 4

func stopLoader(){
    DispatchQueue.main.async {
        SVProgressHUD.dismiss()
    }
}

Thanks!

Related