Advertisement
wa12rior

FlaUI example test case with c# for spotify app

Jan 26th, 2022
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1.         Application application;
  2.         Window? window;
  3.         ConditionFactory cf;
  4.  
  5.         [TestInitialize]
  6.         public void TestInitialize()
  7.         {
  8.             application = Application.Launch(@"C:\Users\<user>\AppData\Roaming\Spotify\Spotify.exe");
  9.             window = application.GetMainWindow(new UIA3Automation());
  10.             cf = new ConditionFactory(new UIA3PropertyLibrary());
  11.  
  12.             System.Threading.Thread.Sleep(2000);
  13.         }
  14.  
  15.         [TestCleanup]
  16.         public void Cleanup()
  17.         {
  18.             System.Threading.Thread.Sleep(2000);
  19.             application.Close();
  20.         }
  21.  
  22.         [TestMethod]
  23.         public void TestShouldNotRegisterWithIncorrectCredentials()
  24.         {
  25.             var email = "test";
  26.             var password = "QWerty123#";
  27.             var salutation = "Test";
  28.  
  29.             window.FindFirstDescendant(cf.ByName("ZAREJESTRUJ SIĘ")).AsButton().Invoke();
  30.             System.Threading.Thread.Sleep(1500);
  31.             window.FindFirstDescendant(cf.ByName("E-mail")).AsTextBox().Enter(email);
  32.             System.Threading.Thread.Sleep(200);
  33.             AutomationElement PasswordBox = null;
  34.             PasswordBox = window.FindFirstDescendant(cf.ByAutomationId("GlueTextInput-4"));
  35.             PasswordBox.FocusNative();
  36.             Keyboard.Type(password);
  37.             System.Threading.Thread.Sleep(200);
  38.             window.FindFirstDescendant(cf.ByName("Jak mamy się do Ciebie zwracać?")).AsTextBox().Enter(salutation);
  39.             window.FindFirstDescendant(cf.ByName("KONTYNUUJ")).AsButton().Invoke();
  40.             System.Threading.Thread.Sleep(200);
  41.             Assert.IsNotNull(window.FindFirstDescendant(cf.ByName("W tym formularzu jest 1 błąd, napraw go przed wysłaniem.")));
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement