Skip to content

Instantly share code, notes, and snippets.

@eyeezzi
Last active December 19, 2018 18:25
Show Gist options
  • Save eyeezzi/3e9b2bc9f75d51d47cfaa68739d98c22 to your computer and use it in GitHub Desktop.
Save eyeezzi/3e9b2bc9f75d51d47cfaa68739d98c22 to your computer and use it in GitHub Desktop.
Testing Flows
import XCTest
class PSUILoginTestsCompact: XCTestCase {
func setUpForFreshInstall() -> XCUIApplication {
let app = XCUIApplication()
app.launchArguments = ["UI_TESTING"]
app.launchEnvironment["SOME_ENV_KEY"] = "SOME_ENV_VALUE"
app.launch()
return app
}
func testLogin() {
let app = setUpForFreshInstall()
let loginButton = app.buttons["Already have a store? Log in"]
waitForElementToExistAndTap(loginButton)
login(app, email: Constants.Login.storeEmail, password: Constants.Login.storePassword, storeName: Constants.Login.storeName)
}
private func login(_ app: XCUIApplication, email: String, password: String, storeName: String?=nil) {
app.tables.textFields["Email address"].tap()
app.tables.textFields["Email address"].typeText(email)
app.tables.secureTextFields["Password"].tap()
app.tables.secureTextFields["Password"].typeText(password)
app.buttons["Log in"].tap()
if let store = storeName {
waitForElementToExist(app.tables.textFields["Store domain"], timeout: 10)
app.tables.textFields["Store domain"].tap()
app.tables.textFields["Store domain"].typeText(store)
app.buttons["Log in"].tap()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment