Guest User

Untitled

a guest
Feb 11th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. namespace FsharpMvvmCross.UITests
  2.  
  3. open System
  4. open NUnit.Framework
  5. open Xamarin.UITest
  6. open Xamarin.UITest.Queries
  7. open TickSpec
  8.  
  9. module LoginScreen =
  10.  
  11. let usernameLabel = "UsernameEntry"
  12. let passwordLabel = "PasswordEntry"
  13. let loginButton = "Login"
  14.  
  15. let enterTextForUsername text (app:IApp) =
  16. app.Tap(fun x -> x.Marked usernameLabel)
  17. app.EnterText text
  18. app.PressEnter()
  19.  
  20. let enterTextForPassword text (app:IApp) =
  21. app.Tap(fun x -> x.Marked passwordLabel)
  22. app.EnterText text
  23. app.PressEnter()
  24.  
  25. let login (app:IApp) =
  26. app.Tap(fun x -> x.Marked loginButton)
  27.  
  28. let canSeeLoginButton (app:IApp) =
  29. app.WaitForElement(fun x -> x.Marked loginButton)
  30. |> Array.filter (fun x -> x.Text = loginButton)
  31. |> function
  32. | [|x|] -> ()
  33. | xs ->
  34. xs |> Array.iter (fun x -> sprintf "%A %s" x.Class x.Text |> Console.WriteLine)
  35. sprintf "failed to find button: %s, %A" loginButton xs |> failwith
  36.  
  37. module NotesScreen =
  38.  
  39. let getNotesButton = "Get Notes"
  40.  
  41. let canSeeGetNotesButton (app:IApp) =
  42. app.WaitForElement(fun x -> x.Marked getNotesButton)
  43. |> Array.filter (fun x -> x.Text = getNotesButton)
  44. |> function
  45. | [|x|] -> ()
  46. | xs ->
  47. xs |> Array.iter (fun x -> sprintf "%A %s" x.Class x.Text |> Console.WriteLine)
  48. sprintf "failed to find button: %s, %A" getNotesButton xs |> failwith
  49.  
  50.  
  51. module LoginDefinitions =
  52.  
  53. let [<Given>] ``I enter the username (.*)`` username =
  54. LoginScreen.enterTextForUsername username AppInitializer.app
  55.  
  56. let [<Given>] ``I enter the password (.*)`` password =
  57. LoginScreen.enterTextForPassword password AppInitializer.app
  58.  
  59. let [<When>] ``I tap login`` () =
  60. LoginScreen.login AppInitializer.app
  61.  
  62. let [<Then>] ``I should be on the Notes screen`` () =
  63. NotesScreen.canSeeGetNotesButton AppInitializer.app
  64.  
  65. let [<Then>] ``I am still on the Login page`` () =
  66. LoginScreen.canSeeLoginButton AppInitializer.app
Add Comment
Please, Sign In to add comment