Search code examples
iosxcodetestingxcode-ui-testingarc4random

using arc4random to generate random number to add to string for UI testing login xcode UI testing


I am testing sign up on an app, using xcode UI testing i am wondering how to use the arc4random to generate a random number which will be typed into the app?

here is my code but getting a type cannont convert value of type UInt32 to expected argument type string.

 let emailBox = self.app.textFields["Email"]
    if emailBox.exists {enter code here
        emailBox.tap()
        emailBox.typeText("testing" + arc4random() + "gmail.com")
    }

Solution

  • let emailBox = self.app.textFields["Email"]
    if emailBox.exists {
        emailBox.tap()
        emailBox.typeText("testing" + String(arc4random()) + "gmail.com")
    }