Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment