Created
February 10, 2019 17:52
-
-
Save willsam100/91ffd1d74db9f72e6ee9772b098cc46d to your computer and use it in GitHub Desktop.
TickSpec tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace FsharpMvvmCross.UITests | |
open System | |
open NUnit.Framework | |
open Xamarin.UITest | |
open Xamarin.UITest.Queries | |
open TickSpec | |
module LoginScreen = | |
let usernameLabel = "UsernameEntry" | |
let passwordLabel = "PasswordEntry" | |
let loginButton = "Login" | |
let enterTextForUsername text (app:IApp) = | |
app.Tap(fun x -> x.Marked usernameLabel) | |
app.EnterText text | |
app.PressEnter() | |
let enterTextForPassword text (app:IApp) = | |
app.Tap(fun x -> x.Marked passwordLabel) | |
app.EnterText text | |
app.PressEnter() | |
let login (app:IApp) = | |
app.Tap(fun x -> x.Marked loginButton) | |
let canSeeLoginButton (app:IApp) = | |
app.WaitForElement(fun x -> x.Marked loginButton) | |
|> Array.filter (fun x -> x.Text = loginButton) | |
|> function | |
| [|x|] -> () | |
| xs -> | |
xs |> Array.iter (fun x -> sprintf "%A %s" x.Class x.Text |> Console.WriteLine) | |
sprintf "failed to find button: %s, %A" loginButton xs |> failwith | |
module NotesScreen = | |
let getNotesButton = "Get Notes" | |
let canSeeGetNotesButton (app:IApp) = | |
app.WaitForElement(fun x -> x.Marked getNotesButton) | |
|> Array.filter (fun x -> x.Text = getNotesButton) | |
|> function | |
| [|x|] -> () | |
| xs -> | |
xs |> Array.iter (fun x -> sprintf "%A %s" x.Class x.Text |> Console.WriteLine) | |
sprintf "failed to find button: %s, %A" getNotesButton xs |> failwith | |
module LoginDefinitions = | |
let [<Given>] ``I enter the username (.*)`` username = | |
LoginScreen.enterTextForUsername username AppInitializer.app | |
let [<Given>] ``I enter the password (.*)`` password = | |
LoginScreen.enterTextForPassword password AppInitializer.app | |
let [<When>] ``I tap login`` () = | |
LoginScreen.login AppInitializer.app | |
let [<Then>] ``I should be on the Notes screen`` () = | |
NotesScreen.canSeeGetNotesButton AppInitializer.app | |
let [<Then>] ``I am still on the Login page`` () = | |
LoginScreen.canSeeLoginButton AppInitializer.app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment