forked from Silverfish/proton-bridge
test(BRIDGE-220): Add Bridge E2E UI login/logout tests for Windows
This commit is contained in:
@ -1,5 +1,8 @@
|
|||||||
using FlaUI.Core.AutomationElements;
|
using FlaUI.Core.AutomationElements;
|
||||||
using FlaUI.Core.Definitions;
|
using FlaUI.Core.Definitions;
|
||||||
|
using ProtonMailBridge.UI.Tests.TestsHelper;
|
||||||
|
using FlaUI.Core.Input;
|
||||||
|
using System.DirectoryServices;
|
||||||
|
|
||||||
namespace ProtonMailBridge.UI.Tests.Results
|
namespace ProtonMailBridge.UI.Tests.Results
|
||||||
{
|
{
|
||||||
@ -9,12 +12,32 @@ namespace ProtonMailBridge.UI.Tests.Results
|
|||||||
private AutomationElement NotificationWindow => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Window));
|
private AutomationElement NotificationWindow => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Window));
|
||||||
private TextBox FreeAccountErrorText => NotificationWindow.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text)).AsTextBox();
|
private TextBox FreeAccountErrorText => NotificationWindow.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text)).AsTextBox();
|
||||||
private TextBox SignedOutAccount => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text)).AsTextBox();
|
private TextBox SignedOutAccount => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text)).AsTextBox();
|
||||||
|
private TextBox AlreadySignedInText => NotificationWindow.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text)).AsTextBox();
|
||||||
|
private Button OkToAcknowledgeAccountAlreadySignedIn => NotificationWindow.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("OK"))).AsButton();
|
||||||
|
private AutomationElement[] TextFields => Window.FindAllDescendants(cf => cf.ByControlType(ControlType.Text));
|
||||||
|
private TextBox SynchronizingField => TextFields[4].AsTextBox();
|
||||||
|
private TextBox AccountDisabledErrorText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("failed to create new API client: 422 POST https://mail-api.proton.me/auth/v4: This account has been suspended due to a potential policy violation. If you believe this is in error, please contact us at https://proton.me/support/appeal-abuse (Code=10003, Status=422)"))).AsTextBox();
|
||||||
|
private TextBox AccountDelinquentErrorText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("failed to create new API client: 422 POST https://mail-api.proton.me/auth/v4: Use of this client requires permissions not available to your account (Code=2011, Status=422)"))).AsTextBox();
|
||||||
|
private TextBox IncorrectLoginCredentialsErrorText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Incorrect login credentials"))).AsTextBox();
|
||||||
|
private TextBox EnterEmailOrUsernameErrorText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Enter email or username"))).AsTextBox();
|
||||||
|
private TextBox EnterPasswordErrorText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Enter password"))).AsTextBox();
|
||||||
|
private TextBox ConnectedStateText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Connected"))).AsTextBox();
|
||||||
|
|
||||||
|
public HomeResult CheckConnectedState()
|
||||||
|
{
|
||||||
|
Assert.That(ConnectedStateText.IsAvailable, Is.True);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public HomeResult CheckIfLoggedIn()
|
public HomeResult CheckIfLoggedIn()
|
||||||
{
|
{
|
||||||
Assert.That(SignOutButton.IsAvailable, Is.True);
|
Assert.That(SignOutButton.IsAvailable, Is.True);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public HomeResult CheckIfSynchronizingBarIsShown()
|
||||||
|
{
|
||||||
|
Assert.That(SynchronizingField.IsAvailable && SynchronizingField.Name.StartsWith("Synchronizing"), Is.True);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public HomeResult CheckIfFreeAccountErrorIsDisplayed(string ErrorText)
|
public HomeResult CheckIfFreeAccountErrorIsDisplayed(string ErrorText)
|
||||||
{
|
{
|
||||||
Assert.That(FreeAccountErrorText.Name == ErrorText, Is.True);
|
Assert.That(FreeAccountErrorText.Name == ErrorText, Is.True);
|
||||||
@ -25,5 +48,46 @@ namespace ProtonMailBridge.UI.Tests.Results
|
|||||||
Assert.That(SignedOutAccount.IsAvailable, Is.True);
|
Assert.That(SignedOutAccount.IsAvailable, Is.True);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public HomeResult CheckIfAccountAlreadySignedInIsDisplayed()
|
||||||
|
{
|
||||||
|
Assert.That(AlreadySignedInText.IsAvailable, Is.True);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public HomeResult ClickOkToAcknowledgeAccountAlreadySignedIn ()
|
||||||
|
{
|
||||||
|
OkToAcknowledgeAccountAlreadySignedIn.Click();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HomeResult CheckIfIncorrectCredentialsErrorIsDisplayed()
|
||||||
|
{
|
||||||
|
Assert.That(IncorrectLoginCredentialsErrorText.IsAvailable, Is.True);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HomeResult CheckIfEnterUsernameAndEnterPasswordErrorMsgsAreDisplayed()
|
||||||
|
{
|
||||||
|
Assert.That(EnterEmailOrUsernameErrorText.IsAvailable && EnterPasswordErrorText.IsAvailable, Is.True);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HomeResult CheckIfDsabledAccountErrorIsDisplayed()
|
||||||
|
{
|
||||||
|
Assert.That(AccountDisabledErrorText.IsAvailable, Is.True);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HomeResult CheckIfDelinquentAccountErrorIsDisplayed()
|
||||||
|
{
|
||||||
|
Assert.That(AccountDelinquentErrorText.IsAvailable, Is.True);
|
||||||
|
return this;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public HomeResult CheckIfNotificationTextIsShown()
|
||||||
|
{
|
||||||
|
Assert.That(AlreadySignedInText.IsAvailable, Is.True);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ namespace ProtonMailBridge.UI.Tests
|
|||||||
App.Kill();
|
App.Kill();
|
||||||
App.Dispose();
|
App.Dispose();
|
||||||
// Give some time to properly exit the app
|
// Give some time to properly exit the app
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LaunchApp()
|
public static void LaunchApp()
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
using ProtonMailBridge.UI.Tests.TestsHelper;
|
using ProtonMailBridge.UI.Tests.TestsHelper;
|
||||||
using ProtonMailBridge.UI.Tests.Windows;
|
using ProtonMailBridge.UI.Tests.Windows;
|
||||||
using ProtonMailBridge.UI.Tests.Results;
|
using ProtonMailBridge.UI.Tests.Results;
|
||||||
|
using FlaUI.Core.Input;
|
||||||
|
|
||||||
namespace ProtonMailBridge.UI.Tests.Tests
|
namespace ProtonMailBridge.UI.Tests.Tests
|
||||||
{
|
{
|
||||||
@ -13,13 +14,6 @@ namespace ProtonMailBridge.UI.Tests.Tests
|
|||||||
private readonly HomeResult _homeResult = new();
|
private readonly HomeResult _homeResult = new();
|
||||||
private readonly string FreeAccountErrorText = "Bridge is exclusive to our mail paid plans. Upgrade your account to use Bridge.";
|
private readonly string FreeAccountErrorText = "Bridge is exclusive to our mail paid plans. Upgrade your account to use Bridge.";
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void LoginAsPaidUser()
|
|
||||||
{
|
|
||||||
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
|
||||||
_homeResult.CheckIfLoggedIn();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void LoginAsFreeUser()
|
public void LoginAsFreeUser()
|
||||||
{
|
{
|
||||||
@ -28,13 +22,128 @@ namespace ProtonMailBridge.UI.Tests.Tests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SuccessfullLogout()
|
public void LoginAsPaidUser()
|
||||||
{
|
{
|
||||||
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void VerifyConnectedState()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
_homeResult.CheckConnectedState();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void VerifyAccountSynchronizingBar()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfSynchronizingBarIsShown();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddAliasAddress()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
_mainWindow.AddNewAccount();
|
||||||
|
_loginWindow.SignIn(TestUserData.GetAliasUser());
|
||||||
|
_homeResult.CheckIfAccountAlreadySignedInIsDisplayed();
|
||||||
|
_homeResult.ClickOkToAcknowledgeAccountAlreadySignedIn();
|
||||||
|
_loginWindow.ClickCancelToSignIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void LoginWithMailboxPassword()
|
||||||
|
{
|
||||||
|
_loginWindow.SignInMailbox(TestUserData.GetMailboxUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
_mainWindow.SignOutAccount();
|
_mainWindow.SignOutAccount();
|
||||||
_homeResult.CheckIfAccountIsSignedOut();
|
_homeResult.CheckIfAccountIsSignedOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddSameAccountTwice()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
_mainWindow.AddNewAccount();
|
||||||
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfAccountAlreadySignedInIsDisplayed();
|
||||||
|
_homeResult.ClickOkToAcknowledgeAccountAlreadySignedIn();
|
||||||
|
_loginWindow.ClickCancelToSignIn();
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddAccountWithWrongCredentials()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetIncorrectCredentialsUser());
|
||||||
|
_homeResult.CheckIfIncorrectCredentialsErrorIsDisplayed();
|
||||||
|
_loginWindow.ClickCancelToSignIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, Order (1)]
|
||||||
|
public void AddAccountWithEmptyCredentials()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetEmptyCredentialsUser());
|
||||||
|
_homeResult.CheckIfEnterUsernameAndEnterPasswordErrorMsgsAreDisplayed();
|
||||||
|
_loginWindow.ClickCancelToSignIn();
|
||||||
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddSameAccountAfterBeingSignedOut()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
_mainWindow.SignOutAccount();
|
||||||
|
Wait.UntilInputIsProcessed(TimeSpan.FromSeconds(3));
|
||||||
|
_mainWindow.ClickSignInMainWindow();
|
||||||
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
_mainWindow.SignOutAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
[Test]
|
||||||
|
public void AddSecondAccount()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
_mainWindow.AddNewAccount();
|
||||||
|
_loginWindow.SignInMailbox(TestUserData.GetMailboxUser());
|
||||||
|
_homeResult.CheckIfLoggedIn();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddDisabledAccount()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetDisabledUser());
|
||||||
|
_homeResult.CheckIfDsabledAccountErrorIsDisplayed();
|
||||||
|
_loginWindow.ClickCancelToSignIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddDeliquentAccount()
|
||||||
|
{
|
||||||
|
_loginWindow.SignIn(TestUserData.GetDeliquentUser());
|
||||||
|
_homeResult.CheckIfDelinquentAccountErrorIsDisplayed();
|
||||||
|
_loginWindow.ClickCancelToSignIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
//[Test]
|
||||||
|
//public void SuccessfullLogout()
|
||||||
|
//{
|
||||||
|
// _loginWindow.SignIn(TestUserData.GetPaidUser());
|
||||||
|
// _mainWindow.SignOutAccount();
|
||||||
|
// _homeResult.CheckIfAccountIsSignedOut();
|
||||||
|
//}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace ProtonMailBridge.UI.Tests.TestsHelper
|
namespace ProtonMailBridge.UI.Tests.TestsHelper
|
||||||
{
|
{
|
||||||
@ -6,31 +7,60 @@ namespace ProtonMailBridge.UI.Tests.TestsHelper
|
|||||||
{
|
{
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
public string MailboxPassword { get; set; }
|
||||||
|
|
||||||
public TestUserData(string username, string password)
|
public TestUserData(string username, string password, string mailboxPassword ="")
|
||||||
{
|
{
|
||||||
Username = username;
|
Username = username;
|
||||||
Password = password;
|
Password = password;
|
||||||
|
MailboxPassword = mailboxPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TestUserData GetFreeUser()
|
public static TestUserData GetFreeUser()
|
||||||
{
|
{
|
||||||
(string username, string password) = GetusernameAndPassword("BRIDGE_FLAUI_FREE_USER");
|
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_FREE_USER");
|
||||||
return new TestUserData(username, password);
|
return new TestUserData(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TestUserData GetPaidUser()
|
public static TestUserData GetPaidUser()
|
||||||
{
|
{
|
||||||
(string username, string password) = GetusernameAndPassword("BRIDGE_FLAUI_PAID_USER");
|
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_PAID_USER");
|
||||||
return new TestUserData(username, password);
|
return new TestUserData(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TestUserData GetMailboxUser()
|
||||||
|
{
|
||||||
|
(string username, string password, string mailboxPassword) = GetUsernameAndPasswordAndMailbox("BRIDGE_FLAUI_MAILBOX_USER");
|
||||||
|
return new TestUserData(username, password, mailboxPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TestUserData GetDisabledUser()
|
||||||
|
{
|
||||||
|
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_DISABLED_USER");
|
||||||
|
return new TestUserData(username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TestUserData GetDeliquentUser()
|
||||||
|
{
|
||||||
|
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_DELIQUENT_USER");
|
||||||
|
return new TestUserData(username, password);
|
||||||
|
}
|
||||||
public static TestUserData GetIncorrectCredentialsUser()
|
public static TestUserData GetIncorrectCredentialsUser()
|
||||||
{
|
{
|
||||||
return new TestUserData("IncorrectUsername", "IncorrectPass");
|
return new TestUserData("IncorrectUsername", "IncorrectPass");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (string, string) GetusernameAndPassword(string userType)
|
public static TestUserData GetEmptyCredentialsUser()
|
||||||
|
{
|
||||||
|
return new TestUserData("", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TestUserData GetAliasUser()
|
||||||
|
{
|
||||||
|
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_ALIAS_USER");
|
||||||
|
return new TestUserData(username, password);
|
||||||
|
}
|
||||||
|
private static (string, string) GetUsernameAndPassword(string userType)
|
||||||
{
|
{
|
||||||
// Get the environment variable for the user and check if missing
|
// Get the environment variable for the user and check if missing
|
||||||
// When changing or adding an environment variable, you must restart Visual Studio
|
// When changing or adding an environment variable, you must restart Visual Studio
|
||||||
@ -38,7 +68,7 @@ namespace ProtonMailBridge.UI.Tests.TestsHelper
|
|||||||
string? str = Environment.GetEnvironmentVariable(userType);
|
string? str = Environment.GetEnvironmentVariable(userType);
|
||||||
if (string.IsNullOrEmpty(str))
|
if (string.IsNullOrEmpty(str))
|
||||||
{
|
{
|
||||||
throw new Exception($"Missing environment variable: {userType}");
|
throw new Exception($"Environment variable {userType} must contain one ':' and it must be between username and password!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the environment variable contains only one ':'
|
// Check if the environment variable contains only one ':'
|
||||||
@ -54,5 +84,34 @@ namespace ProtonMailBridge.UI.Tests.TestsHelper
|
|||||||
string[] split = str.Split(':');
|
string[] split = str.Split(':');
|
||||||
return (split[0], split[1]);
|
return (split[0], split[1]);
|
||||||
}
|
}
|
||||||
|
private static (string, string, string) GetUsernameAndPasswordAndMailbox(string userType)
|
||||||
|
{
|
||||||
|
// Get the environment variable for the user type and check if missing
|
||||||
|
string? str = Environment.GetEnvironmentVariable(userType);
|
||||||
|
if (string.IsNullOrEmpty(str))
|
||||||
|
{
|
||||||
|
throw new Exception($"Missing environment variable: {userType}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the environment variable contains exactly two ':'
|
||||||
|
// The first part is the username, second part is the password, third is the mailbox
|
||||||
|
string separator = ":";
|
||||||
|
string[] parts = str.Split(separator);
|
||||||
|
|
||||||
|
if (parts.Length != 3)
|
||||||
|
{
|
||||||
|
throw new Exception(
|
||||||
|
$"Environment variable {userType} must contain exactly two ':' characters, separating username, password, and mailbox!"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
string username = parts[0];
|
||||||
|
string password = parts[1];
|
||||||
|
string mailbox = parts[2];
|
||||||
|
|
||||||
|
// Return the username, password, and mailbox as a tuple
|
||||||
|
return (username, password, mailbox);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
using FlaUI.Core.AutomationElements;
|
using FlaUI.Core.AutomationElements;
|
||||||
using FlaUI.Core.Definitions;
|
using FlaUI.Core.Definitions;
|
||||||
|
using FlaUI.Core.Conditions;
|
||||||
|
using FlaUI.Core.Input;
|
||||||
|
using ProtonMailBridge.UI.Tests.TestsHelper;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
@ -8,10 +11,14 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
|||||||
public class HomeWindow : UIActions
|
public class HomeWindow : UIActions
|
||||||
{
|
{
|
||||||
private AutomationElement[] AccountViewButtons => AccountView.FindAllChildren(cf => cf.ByControlType(ControlType.Button));
|
private AutomationElement[] AccountViewButtons => AccountView.FindAllChildren(cf => cf.ByControlType(ControlType.Button));
|
||||||
|
private AutomationElement[] HomeButtons => Window.FindAllDescendants(cf => cf.ByControlType(ControlType.Button));
|
||||||
|
private Button AddNewAccountButton => HomeButtons[6].AsButton();
|
||||||
private Button RemoveAccountButton => AccountViewButtons[1].AsButton();
|
private Button RemoveAccountButton => AccountViewButtons[1].AsButton();
|
||||||
private AutomationElement RemoveAccountConfirmModal => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Window));
|
private AutomationElement RemoveAccountConfirmModal => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Window));
|
||||||
private Button ConfirmRemoveAccountButton => RemoveAccountConfirmModal.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Remove this account"))).AsButton();
|
private Button ConfirmRemoveAccountButton => RemoveAccountConfirmModal.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Remove this account"))).AsButton();
|
||||||
private Button SignOutButton => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Sign out"))).AsButton();
|
private Button SignOutButton => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Sign out"))).AsButton();
|
||||||
|
private Button SignInButton => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Sign in"))).AsButton();
|
||||||
|
|
||||||
public HomeWindow RemoveAccount()
|
public HomeWindow RemoveAccount()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -25,10 +32,23 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HomeWindow AddNewAccount ()
|
||||||
|
{
|
||||||
|
AddNewAccountButton.Click();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public HomeWindow SignOutAccount()
|
public HomeWindow SignOutAccount()
|
||||||
{
|
{
|
||||||
SignOutButton.Click();
|
SignOutButton.Click();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public HomeWindow ClickSignInMainWindow()
|
||||||
|
{
|
||||||
|
SignInButton.Click();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
using FlaUI.Core.Input;
|
using FlaUI.Core.Input;
|
||||||
using FlaUI.Core.Definitions;
|
using FlaUI.Core.Definitions;
|
||||||
using ProtonMailBridge.UI.Tests.TestsHelper;
|
using ProtonMailBridge.UI.Tests.TestsHelper;
|
||||||
|
using ProtonMailBridge.UI.Tests.Results;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace ProtonMailBridge.UI.Tests.Windows
|
namespace ProtonMailBridge.UI.Tests.Windows
|
||||||
{
|
{
|
||||||
@ -11,14 +13,32 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
|||||||
private TextBox UsernameInput => InputFields[0].AsTextBox();
|
private TextBox UsernameInput => InputFields[0].AsTextBox();
|
||||||
private TextBox PasswordInput => InputFields[1].AsTextBox();
|
private TextBox PasswordInput => InputFields[1].AsTextBox();
|
||||||
private Button SignInButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Sign in"))).AsButton();
|
private Button SignInButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Sign in"))).AsButton();
|
||||||
|
private Button SigningInButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Signing in"))).AsButton();
|
||||||
private Button StartSetupButton => Window.FindFirstDescendant(cf => cf.ByName("Start setup")).AsButton();
|
private Button StartSetupButton => Window.FindFirstDescendant(cf => cf.ByName("Start setup")).AsButton();
|
||||||
private Button SetUpLater => Window.FindFirstDescendant(cf => cf.ByName("Setup later")).AsButton();
|
private Button SetUpLater => Window.FindFirstDescendant(cf => cf.ByName("Setup later")).AsButton();
|
||||||
|
private TextBox MailboxPasswordInput => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Edit)).AsTextBox();
|
||||||
|
private Button UnlockButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Unlock"))).AsButton();
|
||||||
|
private Button CancelSignIn => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Cancel"))).AsButton();
|
||||||
|
|
||||||
public LoginWindow SignIn(TestUserData user)
|
public LoginWindow SignIn(TestUserData user)
|
||||||
|
{
|
||||||
|
ClickStartSetupButton();
|
||||||
|
EnterCredentials(user);
|
||||||
|
WaitForAuthorizationToComplete(60);
|
||||||
|
|
||||||
|
SetUpLater?.Click();
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoginWindow SignInMailbox(TestUserData user)
|
||||||
{
|
{
|
||||||
ClickStartSetupButton();
|
ClickStartSetupButton();
|
||||||
EnterCredentials(user);
|
EnterCredentials(user);
|
||||||
Wait.UntilInputIsProcessed(TestData.TenSecondsTimeout);
|
Wait.UntilInputIsProcessed(TestData.TenSecondsTimeout);
|
||||||
|
EnterMailboxPassword(user);
|
||||||
|
Wait.UntilInputIsProcessed(TestData.TenSecondsTimeout);
|
||||||
|
|
||||||
SetUpLater?.Click();
|
SetUpLater?.Click();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@ -30,7 +50,6 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
|||||||
SignIn(user);
|
SignIn(user);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginWindow ClickStartSetupButton()
|
public LoginWindow ClickStartSetupButton()
|
||||||
{
|
{
|
||||||
StartSetupButton?.Click();
|
StartSetupButton?.Click();
|
||||||
@ -45,5 +64,38 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
|||||||
SignInButton.Click();
|
SignInButton.Click();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoginWindow EnterMailboxPassword(TestUserData user)
|
||||||
|
{
|
||||||
|
MailboxPasswordInput.Text = user.MailboxPassword;
|
||||||
|
UnlockButton.Click();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoginWindow ClickCancelToSignIn ()
|
||||||
|
{
|
||||||
|
CancelSignIn.Click();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WaitForAuthorizationToComplete(int numOfSeconds)
|
||||||
|
{
|
||||||
|
TimeSpan timeout = TimeSpan.FromSeconds(numOfSeconds);
|
||||||
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||||
|
|
||||||
|
|
||||||
|
while (stopwatch.Elapsed < timeout)
|
||||||
|
{
|
||||||
|
//if Signing in button is not visible authorization process is finished
|
||||||
|
if (SigningInButton == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wait.UntilInputIsProcessed();
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user