I'm trying to use Cucumberish (BDD Framework) in my Swift project. I'm struggling how to wait for the animation between view controllers in order to validate whether the next view controller that I'm showing has the title X or not
This is my .feature file
Feature: Login
As a user
I want to be able to login into the app
so that I can see my account information
Scenario: Login
Given the user is on login screen
When the user enters the username "mbtest12"
When the user enters the password "michal555"
When the user presses login button
Then the loading screen should be shown
Scenario: User forgot his username
Given the user is on login screen
When the user taps Forgot Username
Then the webview screen should be shown with title "Forgot Username"
Scenario: User forgot his password
Given the user is on login screen
When the user taps Forgot Password
Then the webview screen should be shown with title "Forgot Password"
Scenario: User wants to create an account
Given the user is on login screen
When the user taps Create Account
Then the webview screen should be shown with title "Create Account"
Scenario: User wants to see Terms of Use
Given the user is on login screen
When the user taps Terms of Use
Then the webview screen should be shown with title "Terms of Use"
Scenario: User wants to see the Privacy Policy
Given the user is on login screen
When the user taps Privacy Policy
Then the webview screen should be shown with title "Privacy Policy"
This is my LoginSteps.swift file
class LoginSteps {
let loginScreen = LoginScreen()
let webViewScreen = WebViewScreen()
func runSteps() {
beforeStart {
XCUIApplication().launch()
}
Given("the user is on login screen") { (args, userInfo) in
print("Given the user is on login screen")
}
When("^the user enters the username \"(.*)\"$") { (args, userInfo) in
self.loginScreen.fills(username: args![0])
}
When("^the user enters the password \"(.*)\"$") { (args, userInfo) in
self.loginScreen.fills(password: args![0])
}
When("the user presses login button") { (args, userInfo) in
self.loginScreen.tapLoginButton()
}
Then("the loading screen should be shown") { (args, userInfo) in
XCTAssertTrue(self.loginScreen.isLoadingScreenActive())
}
When("the user taps Create Account") { (args, userInfo) in
}
When("the user taps Forgot Username") { (args, userInfo) in
self.loginScreen.tapForgotUsername()
}
When("the user taps Forgot Password") { (args, userInfo) in
self.loginScreen.tapForgotPassword()
}
When("the user taps Terms of Use") { (args, userInfo) in
}
When("the user taps Privacy Policy") { (args, userInfo) in
}
Then("^the webview screen should be shown with title \"(.*)\"$") { (args, userInfo) in
XCTAssertTrue(self.webViewScreen.hasTitle(args![0]))
}
}
}
Check the Scenario: User forgot his username
"When the user taps Forgot Username" means that my WebViewController is about to be shown
When("the user taps Forgot Username") { (args, userInfo) in
self.loginScreen.tapForgotUsername()
}
But there is an animation and I need to wait 'til the WebViewController is presented to get the title and check if it's correct or not
Then("^the webview screen should be shown with title \"(.*)\"$") { (args, userInfo) in
XCTAssertTrue(self.webViewScreen.hasTitle(args![0]))
}
I have the same problem for asynchronous service calls. I know how to use expectation and waitForExpectations methods but I don't how to use them with this framework. Could you please give me some directions or recommend another framework?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire