From a136955cfc6990d8259f09fb9a60e3f75a682612 Mon Sep 17 00:00:00 2001 From: "Angel A. Rodriguez" Date: Thu, 23 Jan 2020 10:42:05 +0100 Subject: [PATCH 1/7] Multi-Factor Authentication is Working / UCI Performance is broke (set disable by default) / Fix Tests is required --- .../DTO/ElementReference.cs | 3 + .../Elements/OnlineLogin.cs | 10 +- ...ft.Dynamics365.UIAutomation.Api.UCI.csproj | 3 + .../WebClient.cs | 279 +++++++++++------- .../packages.config | 1 + .../DTOs/ElementReference.cs | 1 + .../Extensions/SeleniumExtensions.cs | 1 - ...oft.Dynamics365.UIAutomation.Sample.csproj | 2 + .../Properties/AssemblyInfo.cs | 1 - .../SharedAPI/AzureInsights/OpenLead.cs | 1 - .../SharedAPI/BrowserTests/BrowserTests.cs | 1 - .../TestSettings.cs | 2 +- .../UCI/Create/CreateAccount.cs | 33 +-- .../UCI/Login/Login.cs | 27 ++ .../UCI/TestsBase.cs | 55 ++++ .../app.config | 7 +- 16 files changed, 285 insertions(+), 142 deletions(-) create mode 100644 Microsoft.Dynamics365.UIAutomation.Sample/UCI/Login/Login.cs create mode 100644 Microsoft.Dynamics365.UIAutomation.Sample/UCI/TestsBase.cs diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/ElementReference.cs b/Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/ElementReference.cs index 446bff66..a2547a08 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/ElementReference.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/ElementReference.cs @@ -183,6 +183,8 @@ public static class Elements { "Login_SignIn", "id(\"cred_sign_in_button\")"}, { "Login_CrmMainPage", "//*[contains(@id,'crmTopBar')or contains(@data-id,'topBar')]"}, { "Login_StaySignedIn", "//input[@id=\"idSIButton9\"]"}, + { "Login_OneTimeCode", "//input[@name='otc']"}, + //Notification { "Notification_AppMessageBar", "id(\"crmAppMessageBar\")"}, @@ -724,6 +726,7 @@ public static class Login public static string SignIn = "Login_SignIn"; public static string CrmMainPage = "Login_CrmMainPage"; public static string StaySignedIn = "Login_StaySignedIn"; + public static string OneTimeCode = "Login_OneTimeCode"; } public static class Report { diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/OnlineLogin.cs b/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/OnlineLogin.cs index fe736071..41dbac14 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/OnlineLogin.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/OnlineLogin.cs @@ -32,9 +32,10 @@ public void Login(Uri orgUrl) /// URL of the organization /// User name /// Password - public void Login(Uri orgUrl, SecureString username, SecureString password) + /// SecrectKey for multi-factor authentication + public void Login(Uri orgUrl, SecureString username, SecureString password, SecureString mfaSecrectKey = null) { - _client.Login(orgUrl, username, password); + _client.Login(orgUrl, username, password, mfaSecrectKey); _client.InitializeModes(true); } @@ -45,10 +46,11 @@ public void Login(Uri orgUrl, SecureString username, SecureString password) /// URL of the organization /// User name /// Password + /// SecrectKey for multi-factor authentication /// Actions required during redirect - public void Login(Uri orgUrl, SecureString username, SecureString password, Action redirectAction) + public void Login(Uri orgUrl, SecureString username, SecureString password, SecureString mfaSecrectKey, Action redirectAction) { - _client.Login(orgUrl, username, password, redirectAction); + _client.Login(orgUrl, username, password, mfaSecrectKey, redirectAction); _client.InitializeModes(true); } diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/Microsoft.Dynamics365.UIAutomation.Api.UCI.csproj b/Microsoft.Dynamics365.UIAutomation.Api.UCI/Microsoft.Dynamics365.UIAutomation.Api.UCI.csproj index 586cfd3b..6491e94e 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/Microsoft.Dynamics365.UIAutomation.Api.UCI.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/Microsoft.Dynamics365.UIAutomation.Api.UCI.csproj @@ -40,6 +40,9 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True + + ..\packages\Otp.NET.1.2.1\lib\net45\Otp.NET.dll + ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs b/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs index d65285ef..6ecd8826 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs @@ -6,12 +6,12 @@ using OpenQA.Selenium.Support.UI; using System; using System.Collections.Generic; -using System.Collections.Specialized; +using System.Diagnostics; using System.Linq; using System.Security; using System.Threading; using System.Web; -using System.Web.Script.Serialization; +using OtpNet; namespace Microsoft.Dynamics365.UIAutomation.Api.UCI { @@ -31,8 +31,8 @@ internal BrowserCommandOptions GetOptions(string commandName) { return new BrowserCommandOptions(Constants.DefaultTraceSource, commandName, - 0, - 0, + Constants.DefaultRetryAttempts, + Constants.DefaultRetryDelay, null, true, typeof(NoSuchElementException), typeof(StaleElementReferenceException)); @@ -72,49 +72,57 @@ internal BrowserCommandResult InitializeModes(bool onlineLoginPath = false #region Login internal BrowserCommandResult Login(Uri uri) { - if (this.Browser.Options.Credentials.Username == null) + var username = Browser.Options.Credentials.Username; + if (username == null) return PassThroughLogin(uri); - else - return this.Execute(GetOptions("Login"), this.Login, uri, this.Browser.Options.Credentials.Username, this.Browser.Options.Credentials.Password, default(Action)); - } - internal BrowserCommandResult Login(Uri orgUri, SecureString username, SecureString password) - { - return this.Execute(GetOptions("Login"), this.Login, orgUri, username, password, default(Action)); + var password = Browser.Options.Credentials.Password; + return Login(uri, username, password); } - internal BrowserCommandResult Login(Uri orgUri, SecureString username, SecureString password, Action redirectAction) + internal BrowserCommandResult Login(Uri orgUri, SecureString username, SecureString password, SecureString mfaSecrectKey = null, Action redirectAction = null) { - return this.Execute(GetOptions("Login"), this.Login, orgUri, username, password, redirectAction); + return Execute(GetOptions("Login"), Login, orgUri, username, password, mfaSecrectKey, redirectAction); } - private LoginResult Login(IWebDriver driver, Uri uri, SecureString username, SecureString password, - Action redirectAction) + private LoginResult Login(IWebDriver driver, Uri uri, SecureString username, SecureString password, SecureString mfaSecrectKey = null, Action redirectAction = null) { - var redirect = false; - bool online = !(this.OnlineDomains != null && !this.OnlineDomains.Any(d => uri.Host.EndsWith(d))); + bool online = !(OnlineDomains != null && !OnlineDomains.Any(d => uri.Host.EndsWith(d))); driver.Navigate().GoToUrl(uri); - if (online) + if (!online) + return LoginResult.Success; + + if (driver.IsVisible(By.Id("use_another_account_link"))) + driver.ClickWhenAvailable(By.Id("use_another_account_link")); + + bool waitingForOtc = false; + bool success = EnterUserName(driver, username); + if (!success) { - if (driver.IsVisible(By.Id("use_another_account_link"))) - driver.ClickWhenAvailable(By.Id("use_another_account_link")); + var isUserAlreadyLogged = IsUserAlreadyLogged(driver); + if (isUserAlreadyLogged) + { + SwitchToDefaultContent(driver); + return LoginResult.Success; + } - driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.Login.UserId]), - $"The Office 365 sign in page did not return the expected result and the user '{username}' could not be signed in."); + waitingForOtc = GetOtcInput(driver) != null; - driver.FindElement(By.XPath(Elements.Xpath[Reference.Login.UserId])).SendKeys(username.ToUnsecureString()); - driver.FindElement(By.XPath(Elements.Xpath[Reference.Login.UserId])).SendKeys(Keys.Tab); - driver.FindElement(By.XPath(Elements.Xpath[Reference.Login.UserId])).SendKeys(Keys.Enter); + if (!waitingForOtc) + throw new Exception($"Login page failed. {Reference.Login.UserId} not found."); + } - Thread.Sleep(1000); + if (!waitingForOtc) + { + ThinkTime(1000); if (driver.IsVisible(By.Id("aadTile"))) { driver.FindElement(By.Id("aadTile")).Click(true); } - Thread.Sleep(1000); + ThinkTime(1000); //If expecting redirect then wait for redirect to trigger if (redirectAction != null) @@ -122,41 +130,112 @@ private LoginResult Login(IWebDriver driver, Uri uri, SecureString username, Sec //Wait for redirect to occur. Thread.Sleep(3000); - redirectAction?.Invoke(new LoginRedirectEventArgs(username, password, driver)); - - redirect = true; + redirectAction.Invoke(new LoginRedirectEventArgs(username, password, driver)); + return LoginResult.Redirect; } - else - { - driver.FindElement(By.XPath(Elements.Xpath[Reference.Login.LoginPassword])).SendKeys(password.ToUnsecureString()); - driver.FindElement(By.XPath(Elements.Xpath[Reference.Login.LoginPassword])).SendKeys(Keys.Tab); - driver.FindElement(By.XPath(Elements.Xpath[Reference.Login.LoginPassword])).Submit(); - Thread.Sleep(1000); + EnterPassword(driver, password); + ThinkTime(1000); + } - driver.WaitUntilVisible(By.XPath(Elements.Xpath[Reference.Login.StaySignedIn]), new TimeSpan(0, 0, 5)); + EnterOneTimeCode(driver, mfaSecrectKey); + + ClickStaySignedIn(driver); - if (driver.IsVisible(By.XPath(Elements.Xpath[Reference.Login.StaySignedIn]))) - { - driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Login.StaySignedIn])); - } + ThinkTime(1000); - driver.WaitUntilVisible(By.XPath(Elements.Xpath[Reference.Login.CrmMainPage]) - , new TimeSpan(0, 0, 60), - e => { - e.WaitForPageToLoad(); - e.SwitchTo().Frame(0); - e.WaitForPageToLoad(); + var xpathToMainPage = By.XPath(Elements.Xpath[Reference.Login.CrmMainPage]); + driver.WaitUntilVisible(xpathToMainPage + , new TimeSpan(0, 0, 60), + e => SwitchToDefaultContent(driver), + f => throw new Exception($"Login page failed. {Reference.Login.CrmMainPage} not found.")); - //Switch Back to Default Content for Navigation Steps - e.SwitchTo().DefaultContent(); - }, - f => { throw new Exception("Login page failed."); }); + return LoginResult.Success; + } + + private static bool IsUserAlreadyLogged(IWebDriver driver) + { + var xpathToMainPage = By.XPath(Elements.Xpath[Reference.Login.CrmMainPage]); + bool result = driver.HasElement(xpathToMainPage); + return result; + } + + private static string GenerateOneTimeCode(SecureString mfaSecrectKey) + { + // credits: + // https://dev.to/j_sakamoto/selenium-testing---how-to-sign-in-to-two-factor-authentication-2joi + // https://www.nuget.org/packages/Otp.NET/ + string key = mfaSecrectKey?.ToUnsecureString(); // <- this 2FA secret key. + + byte[] base32Bytes = Base32Encoding.ToBytes(key); + + var totp = new Totp(base32Bytes); + var result = totp.ComputeTotp(); // <- got 2FA coed at this time! + return result; + } + + private bool EnterUserName(IWebDriver driver, SecureString username) + { + var input = driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.Login.UserId]), new TimeSpan(0, 0, 30)); + if (input == null) + return false; + + input.SendKeys(username.ToUnsecureString()); + input.SendKeys(Keys.Enter); + return true; + } + + private static void EnterPassword(IWebDriver driver, SecureString password) + { + var input = driver.FindElement(By.XPath(Elements.Xpath[Reference.Login.LoginPassword])); + input.SendKeys(password.ToUnsecureString()); + input.Submit(); + } + + private static void EnterOneTimeCode(IWebDriver driver, SecureString mfaSecrectKey) + { + int attempts = 0; + while (true) + { + try + { + IWebElement input = GetOtcInput(driver); + var oneTimeCode = GenerateOneTimeCode(mfaSecrectKey); + input.SendKeys(oneTimeCode); + input.Submit(); + return; + } + catch (Exception e) + { + Trace.TraceWarning($"An Error ocur entering OTC. Exception: {e}"); + if (attempts >= Constants.DefaultRetryAttempts) + throw; + Thread.Sleep(Constants.DefaultRetryDelay); + attempts++; } } + } - return redirect ? LoginResult.Redirect : LoginResult.Success; + private static IWebElement GetOtcInput(IWebDriver driver) + => driver.FindElement(By.XPath(Elements.Xpath[Reference.Login.OneTimeCode])); + + private static void ClickStaySignedIn(IWebDriver driver) + { + var xpath = By.XPath(Elements.Xpath[Reference.Login.StaySignedIn]); + driver.WaitUntilVisible(xpath, new TimeSpan(0, 0, 5), + e => driver.ClickWhenAvailable(xpath)); } + + private static void SwitchToDefaultContent(IWebDriver driver) + { + driver.WaitForPageToLoad(); + driver.SwitchTo().Frame(0); + driver.WaitForPageToLoad(); + + //Switch Back to Default Content for Navigation Steps + driver.SwitchTo().DefaultContent(); + } + internal BrowserCommandResult PassThroughLogin(Uri uri) { return this.Execute(GetOptions("Pass Through Login"), driver => @@ -165,15 +244,8 @@ internal BrowserCommandResult PassThroughLogin(Uri uri) driver.WaitUntilVisible(By.XPath(Elements.Xpath[Reference.Login.CrmMainPage]) , new TimeSpan(0, 0, 60), - e => { - e.WaitForPageToLoad(); - e.SwitchTo().Frame(0); - e.WaitForPageToLoad(); - - //Switch Back to Default Content for Navigation Steps - e.SwitchTo().DefaultContent(); - }, - f => { throw new Exception("Login page failed."); }); + e => SwitchToDefaultContent(driver), + f => throw new Exception("Login page failed.")); return LoginResult.Success; }); @@ -254,10 +326,11 @@ internal BrowserCommandResult OpenApp(string appName, int thinkTime = Cons { driver.SwitchTo().DefaultContent(); - //Handle left hand Nav - if (driver.HasElement(By.XPath(AppElements.Xpath[AppReference.Navigation.AppMenuButton]))) + // Handle left hand Nav + var xpathToAppMenu = By.XPath(AppElements.Xpath[AppReference.Navigation.AppMenuButton]); + if (driver.HasElement(xpathToAppMenu)) { - driver.ClickWhenAvailable(By.XPath(AppElements.Xpath[AppReference.Navigation.AppMenuButton])); + driver.ClickWhenAvailable(xpathToAppMenu); var container = driver.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.Navigation.AppMenuContainer])); @@ -275,36 +348,46 @@ internal BrowserCommandResult OpenApp(string appName, int thinkTime = Cons driver.WaitForPageToLoad(); driver.WaitForTransaction(); - } - else if (driver.HasElement(By.XPath(AppElements.Xpath[AppReference.Navigation.UCIAppContainer]))) //Handle main.aspx?ForcUCI=1 - { - var tileContainer = driver.FindElement(By.XPath(AppElements.Xpath[AppReference.Navigation.UCIAppContainer])); - tileContainer.FindElement(By.XPath(AppElements.Xpath[AppReference.Navigation.UCIAppTile].Replace("[NAME]", appName))).Click(true); - driver.WaitForTransaction(); + return true; } - else - { - //Switch to frame 0 - driver.SwitchTo().Frame(0); - if (driver.HasElement(By.XPath(AppElements.Xpath[AppReference.Navigation.UCIAppContainer]))) - { - var tileContainer = driver.FindElement(By.XPath(AppElements.Xpath[AppReference.Navigation.UCIAppContainer])); - tileContainer.FindElement(By.XPath(AppElements.Xpath[AppReference.Navigation.UCIAppTile].Replace("[NAME]", appName))).Click(true); + //Handle main.aspx?forceUCI=1 + // TODO: REMOVE COMMENTS FOR OLDER CRM Versions current v9.1 + //bool success = TryToClickInAppTile(driver, appName); + //if (!success) + //{ + //Switch to frame 0 + driver.SwitchTo().Frame(0); - driver.WaitForTransaction(); - } - else - throw new InvalidOperationException($"App Name {appName} not found."); - } + bool success = TryToClickInAppTile(driver, appName); + if (!success) + throw new InvalidOperationException($"App Name {appName} not found."); + //} InitializeModes(); - return true; }); } + private bool TryToClickInAppTile(IWebDriver driver, string appName) + { + var xpathToAppContainer = By.XPath(AppElements.Xpath[AppReference.Navigation.UCIAppContainer]); + var xpathToAppTile = By.XPath(AppElements.Xpath[AppReference.Navigation.UCIAppTile].Replace("[NAME]", appName)); + + var tileContainer = driver.WaitUntilAvailable(xpathToAppContainer, new TimeSpan(0, 0, 15)); + + var appTile = tileContainer?.FindElement(xpathToAppTile); + if (appTile == null) + return false; + + appTile.Click(true); + + driver.WaitForTransaction(); + InitializeModes(); + return true; + } + internal BrowserCommandResult OpenGroupSubArea(string group, string subarea, int thinkTime = Constants.DefaultThinkTime) { this.Browser.ThinkTime(thinkTime); @@ -394,30 +477,13 @@ internal BrowserCommandResult OpenSubArea(string area, string subarea, int public BrowserCommandResult> OpenAreas(string area, int thinkTime = Constants.DefaultThinkTime) { - return this.Execute(GetOptions("Open Unified Interface Area"), driver => + return Execute(GetOptions("Open Unified Interface Area"), driver => { - - //9.0.2 - var areas = OpenMenu().Value; - - if (areas != null) - { - if (!areas.ContainsKey(area)) - { - throw new InvalidOperationException($"No area with the name '{area}' exists."); - } - - return areas; - } - - //9.1 - areas = OpenMenuFallback(area).Value; + // 9.1 ?? 9.0.2 <- inverted order (fallback first) run quickly + var areas = OpenMenuFallback(area).Value ?? OpenMenu().Value; if (!areas.ContainsKey(area)) - { - // In this scenario - throw new InvalidOperationException($"No area with the name '{area}' exists."); - } return areas; }); @@ -484,10 +550,7 @@ public BrowserCommandResult> OpenMenuFallback(st dictionary.Add(item.Text.ToLowerString(), item); } }, - e => - { - throw new InvalidOperationException("The Main Menu is not available."); - }); + e => throw new InvalidOperationException("The Main Menu is not available.")); } if (driver.HasElement(By.XPath(AppElements.Xpath[AppReference.Navigation.SiteMapAreaMoreButton]))) diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/packages.config b/Microsoft.Dynamics365.UIAutomation.Api.UCI/packages.config index b6bb0eab..8aa1f99d 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/packages.config +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/packages.config @@ -2,6 +2,7 @@ + diff --git a/Microsoft.Dynamics365.UIAutomation.Api/DTOs/ElementReference.cs b/Microsoft.Dynamics365.UIAutomation.Api/DTOs/ElementReference.cs index 0e13b8bb..60d63410 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api/DTOs/ElementReference.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api/DTOs/ElementReference.cs @@ -250,6 +250,7 @@ public static class Elements { "Login_SignIn", "id(\"cred_sign_in_button\")"}, { "Login_CrmMainPage", "id(\"crmTopBar\")"}, { "Login_StaySignedIn", "id(\"idSIButton9\")"}, + { "Login_OneTimeCode", "//input[@name='otc']"}, //Notification { "Notification_AppMessageBar", "id(\"crmAppMessageBar\")"}, diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs b/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs index 99a5eb36..2f62078a 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs @@ -12,7 +12,6 @@ using System.Drawing; using System.IO; using System.Linq; -using System.Threading; using System.Web.Script.Serialization; namespace Microsoft.Dynamics365.UIAutomation.Browser diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj b/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj index 1d972ef8..4615f1f1 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj @@ -102,6 +102,7 @@ + @@ -110,6 +111,7 @@ + diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/Properties/AssemblyInfo.cs b/Microsoft.Dynamics365.UIAutomation.Sample/Properties/AssemblyInfo.cs index 12ff07f9..fedaea7c 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/Properties/AssemblyInfo.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/SharedAPI/AzureInsights/OpenLead.cs b/Microsoft.Dynamics365.UIAutomation.Sample/SharedAPI/AzureInsights/OpenLead.cs index c364c61a..b943dd87 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/SharedAPI/AzureInsights/OpenLead.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/SharedAPI/AzureInsights/OpenLead.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using Microsoft.Dynamics365.UIAutomation.Api; using Microsoft.Dynamics365.UIAutomation.Browser; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/SharedAPI/BrowserTests/BrowserTests.cs b/Microsoft.Dynamics365.UIAutomation.Sample/SharedAPI/BrowserTests/BrowserTests.cs index c7abf3b5..2581b861 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/SharedAPI/BrowserTests/BrowserTests.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/SharedAPI/BrowserTests/BrowserTests.cs @@ -1,5 +1,4 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.Dynamics365.UIAutomation.Api; using Microsoft.Dynamics365.UIAutomation.Browser; namespace Microsoft.Dynamics365.UIAutomation.Sample.SharedAPI diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs b/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs index 0ad1cb96..1b48ea88 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs @@ -28,7 +28,7 @@ public static class TestSettings RemoteBrowserType = (BrowserType)Enum.Parse(typeof(BrowserType), RemoteType), RemoteHubServer = new Uri(RemoteHubServerURL), UCITestMode = true, - UCIPerformanceMode = true + UCIPerformanceMode = false }; public static string GetRandomString(int minLen, int maxLen) diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateAccount.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateAccount.cs index 26777176..3634b825 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateAccount.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateAccount.cs @@ -2,41 +2,30 @@ // Licensed under the MIT license. using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class CreateAccountUCI + public class CreateAccount : TestsBase { + [TestInitialize] + public override void InitTest() => base.InitTest(); - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); + [TestCleanup] + public override void FinishTest() => base.FinishTest(); + + public override void NavigateToHomePage() => _xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); [TestMethod] public void UCITestCreateAccount() { - var client = new WebClient(TestSettings.Options); - using (var xrmApp = new XrmApp(client)) - { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); - - xrmApp.Navigation.OpenApp(UCIAppName.Sales); - - xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); + _xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); - xrmApp.CommandBar.ClickCommand("New"); + _xrmApp.CommandBar.ClickCommand("New"); - xrmApp.Entity.SetValue("name", TestSettings.GetRandomString(5,15)); + _xrmApp.Entity.SetValue("name", TestSettings.GetRandomString(5, 15)); - xrmApp.Entity.Save(); - - } - + _xrmApp.Entity.Save(); } } } \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Login/Login.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Login/Login.cs new file mode 100644 index 00000000..212e42b3 --- /dev/null +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Login/Login.cs @@ -0,0 +1,27 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI.Login +{ + [TestClass] + public class Login : TestsBase + { + [TestInitialize] + public override void InitTest() => base.InitTest(); + + [TestCleanup] + public override void FinishTest() => base.FinishTest(); + + public override void NavigateToHomePage() => _xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); + + [TestMethod] + public void MultiFactorLogin() + { + _xrmApp.Grid.SwitchView("All Accounts"); + + _xrmApp.CommandBar.ClickCommand("New"); + + _xrmApp.Entity.SetValue("name", _timed("Test API Account")); + _xrmApp.Entity.SetValue("telephone1", "555-555-5555"); + } + } +} \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/TestsBase.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/TestsBase.cs new file mode 100644 index 00000000..10a40bd5 --- /dev/null +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/TestsBase.cs @@ -0,0 +1,55 @@ +// Created by: Rodriguez Mustelier Angel (rodang) +// Modify On: 2020-01-23 02:51 + +using System; +using System.Configuration; +using System.Security; +using Microsoft.Dynamics365.UIAutomation.Api.UCI; +using Microsoft.Dynamics365.UIAutomation.Browser; + +namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI +{ + public class TestsBase + { + protected readonly Uri _xrmUri = new Uri(ConfigurationManager.AppSettings["OnlineCrmUrl"]); + protected readonly SecureString _username = ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); + protected readonly SecureString _password = ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); + protected readonly SecureString _mfaSecrectKey = ConfigurationManager.AppSettings["MfaSecrectKey"].ToSecureString(); + protected readonly bool _usePrivateMode = Convert.ToBoolean(ConfigurationManager.AppSettings["UsePrivateMode"]); + + protected XrmApp _xrmApp; + protected string _timed(string value) => $"{value} {DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}"; + + public virtual void InitTest() + { + CreateApp(); + NavigateToHomePage(); + } + + public virtual void FinishTest() + { + CloseApp(); + } + + public void CreateApp(bool privateMode = true) + { + BrowserOptions options = TestSettings.Options; + options.PrivateMode = privateMode || _usePrivateMode; + options.UCIPerformanceMode = false; + + var client = new WebClient(options); + _xrmApp = new XrmApp(client); + + _xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); + _xrmApp.Navigation.OpenApp(UCIAppName.Sales); + } + + public void CloseApp() + { + _xrmApp.Dispose(); + _xrmApp = null; + } + + public virtual void NavigateToHomePage() { } + } +} \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/app.config b/Microsoft.Dynamics365.UIAutomation.Sample/app.config index 00a348e7..4c456982 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/app.config +++ b/Microsoft.Dynamics365.UIAutomation.Sample/app.config @@ -11,9 +11,10 @@ - - - + + + + From fbfc3c758b12ef2bef0ee80f4ba2f6ee918d4b40 Mon Sep 17 00:00:00 2001 From: "Angel A. Rodriguez" Date: Thu, 23 Jan 2020 10:43:01 +0100 Subject: [PATCH 2/7] Add MFA Key to UCI Tests --- .../BusinessProcessFlowNextStage.cs | 31 ++++------- .../SwitchBusinessProcessFlow.cs | 31 +++++------ .../UCI/CommandBar/AssignAccount.cs | 34 +++++------- .../UCI/CommandBar/CloseOpportunity.cs | 32 +++++------ .../UCI/CommandBar/CommandButton.cs | 53 ++++++------------- .../UCI/CommandBar/DuplicateDetection.cs | 36 +++++-------- .../UCI/CommandBar/SelectDashboard.cs | 27 +++------- .../UCI/Controls/Grid.cs | 4 +- .../UCI/Create/CreateActivity.cs | 13 +---- .../UCI/Create/CreateCase.cs | 14 +---- .../UCI/Create/CreateContact.cs | 12 +---- .../UCI/Create/CreateLead.cs | 14 +---- .../UCI/Create/CreateOpportunity.cs | 13 ++--- .../UCI/Delete/DeleteAccount.cs | 12 +---- .../UCI/Delete/DeleteCase.cs | 14 +---- .../UCI/Delete/DeleteContact.cs | 12 +---- .../UCI/Delete/DeleteLead.cs | 11 +--- .../UCI/Delete/DeleteOpportunity.cs | 12 +---- .../UCI/GetValue.cs | 16 ++---- .../GlobalSearch/GlobalCategorizedSearch.cs | 11 +--- .../UCI/GlobalSearch/GlobalRelevanceSearch.cs | 11 +--- .../UCI/Navigation/FormSelector.cs | 11 +--- .../UCI/Navigation/GlobalSearch.cs | 11 +--- .../UCI/Navigation/OpenNavigation.cs | 23 +++----- .../UCI/Navigation/PortalAdmin.cs | 11 +--- .../UCI/QuickCreate/QuickCreate.cs | 14 ++--- .../UCI/Read/HighlightAccount.cs | 12 +---- .../UCI/Read/OpenAccount.cs | 19 +++---- .../UCI/Read/OpenCase.cs | 16 ++---- .../UCI/Read/OpenContact.cs | 24 +++------ .../UCI/Read/OpenLead.cs | 18 ++----- .../UCI/Read/OpenOpportunity.cs | 16 ++---- .../UCI/SetValue.cs | 24 ++++----- .../RandomAccountTest.cs | 12 +---- .../UCI/Timeline/AddActivity.cs | 21 +++----- .../UCI/Timeline/AddNote.cs | 11 +--- .../UCI/Timeline/AddPost.cs | 11 +--- .../UCI/Update/UpdateAccount.cs | 12 +---- .../UCI/Update/UpdateCase.cs | 14 ++--- .../UCI/Update/UpdateContact.cs | 16 ++---- .../UCI/Update/UpdateLead.cs | 14 ++--- .../UCI/Update/UpdateOpportunity.cs | 12 +---- .../UCI/Validate/CheckFieldRequired.cs | 14 ++--- 43 files changed, 202 insertions(+), 547 deletions(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/BusinessProcessFlow/BusinessProcessFlowNextStage.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/BusinessProcessFlow/BusinessProcessFlowNextStage.cs index 7c062526..a2402399 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/BusinessProcessFlow/BusinessProcessFlowNextStage.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/BusinessProcessFlow/BusinessProcessFlowNextStage.cs @@ -2,36 +2,25 @@ // Licensed under the MIT license. using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class BusinessProcessFlowNextStageUCI + public class BusinessProcessFlowNextStage : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); + [TestInitialize] + public override void InitTest() => base.InitTest(); + + [TestCleanup] + public override void FinishTest() => base.FinishTest(); + + public override void NavigateToHomePage() => _xrmApp.Navigation.OpenSubArea("Sales", "Leads"); [TestMethod] public void UCITestBusinessProcessFlowNextStage() { - var client = new WebClient(TestSettings.Options); - using (var xrmApp = new XrmApp(client)) - { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); - - xrmApp.Navigation.OpenApp(UCIAppName.Sales); - - xrmApp.Navigation.OpenSubArea("Sales", "Leads"); - - xrmApp.Grid.OpenRecord(0); - - xrmApp.BusinessProcessFlow.NextStage("Qualify"); - } + _xrmApp.Grid.OpenRecord(0); + _xrmApp.BusinessProcessFlow.NextStage("Qualify"); } } } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/BusinessProcessFlow/SwitchBusinessProcessFlow.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/BusinessProcessFlow/SwitchBusinessProcessFlow.cs index d2780275..8c6a48a6 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/BusinessProcessFlow/SwitchBusinessProcessFlow.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/BusinessProcessFlow/SwitchBusinessProcessFlow.cs @@ -2,37 +2,30 @@ // Licensed under the MIT license. using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class SwitchBusinessProcessFlowUCI + public class SwitchBusinessProcessFlow : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); + [TestInitialize] + public override void InitTest() => base.InitTest(); + + [TestCleanup] + public override void FinishTest() => base.FinishTest(); + + public override void NavigateToHomePage() => _xrmApp.Navigation.OpenSubArea("Sales", "Leads"); [TestMethod] public void UCITestSwitchBusinessProcessFlow() { - var client = new WebClient(TestSettings.Options); - using (var xrmApp = new XrmApp(client)) - { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); - - xrmApp.Navigation.OpenApp(UCIAppName.Sales); + _xrmApp.Navigation.OpenSubArea("Sales", "Leads"); - xrmApp.Navigation.OpenSubArea("Sales", "Leads"); + _xrmApp.Grid.OpenRecord(0); - xrmApp.Grid.OpenRecord(0); + //xrmApp.Entity.SwitchProcess("AccountEventingProcess"); + _xrmApp.Entity.SwitchProcess("Lead to Opportunity Sales Process"); - //xrmApp.Entity.SwitchProcess("AccountEventingProcess"); - xrmApp.Entity.SwitchProcess("Lead to Opportunity Sales Process"); - } } } } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/AssignAccount.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/AssignAccount.cs index f05e4caf..ed719eaf 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/AssignAccount.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/AssignAccount.cs @@ -3,41 +3,31 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class AssignAccountUCI + public class AssignAccount : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); + [TestInitialize] + public override void InitTest() => base.InitTest(); + + [TestCleanup] + public override void FinishTest() => base.FinishTest(); + + public override void NavigateToHomePage() => _xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); [TestMethod] public void UCITestAssignAccount() { - var client = new WebClient(TestSettings.Options); - using (var xrmApp = new XrmApp(client)) - { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); - - xrmApp.Navigation.OpenApp(UCIAppName.Sales); - - xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); - - xrmApp.Grid.OpenRecord(0); - - xrmApp.ThinkTime(2000); + _xrmApp.Grid.OpenRecord(0); - xrmApp.CommandBar.ClickCommand("Assign"); + _xrmApp.ThinkTime(2000); - xrmApp.Dialogs.Assign(Dialogs.AssignTo.User, "Grant"); + _xrmApp.CommandBar.ClickCommand("Assign"); - } + _xrmApp.Dialogs.Assign(Dialogs.AssignTo.User, "Grant"); } } } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/CloseOpportunity.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/CloseOpportunity.cs index 045bca87..f09a6373 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/CloseOpportunity.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/CloseOpportunity.cs @@ -2,39 +2,31 @@ // Licensed under the MIT license. using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class CloseOpportunityUCI + public class CloseOpportunity : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); + [TestInitialize] + public override void InitTest() => base.InitTest(); + + [TestCleanup] + public override void FinishTest() => base.FinishTest(); + + public override void NavigateToHomePage() => _xrmApp.Navigation.OpenSubArea("Sales", "Opportunities"); [TestMethod] public void UCITestCloseOpportunity() { - var client = new WebClient(TestSettings.Options); - using (var xrmApp = new XrmApp(client)) - { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); - - xrmApp.Navigation.OpenApp(UCIAppName.Sales); - - xrmApp.Navigation.OpenSubArea("Sales", "Opportunities"); - - xrmApp.Grid.OpenRecord(0); + _xrmApp.Navigation.OpenSubArea("Sales", "Opportunities"); - xrmApp.CommandBar.ClickCommand("Close as Won"); + _xrmApp.Grid.OpenRecord(0); - xrmApp.Dialogs.CloseOpportunity(123.45, DateTime.Now, "test"); + _xrmApp.CommandBar.ClickCommand("Close as Won"); - } + _xrmApp.Dialogs.CloseOpportunity(123.45, DateTime.Now, "test"); } } } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/CommandButton.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/CommandButton.cs index f11947ea..3f43ca1b 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/CommandButton.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/CommandButton.cs @@ -2,59 +2,38 @@ // Licensed under the MIT license. using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Collections.Generic; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class CommandButton + public class CommandButton : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); + [TestInitialize] + public override void InitTest() => base.InitTest(); + + [TestCleanup] + public override void FinishTest() => base.FinishTest(); + + public override void NavigateToHomePage() => _xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); [TestMethod] public void UCITestNewCommandBarButton() { - var client = new WebClient(TestSettings.Options); - using (var xrmApp = new XrmApp(client)) - { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); - - xrmApp.Navigation.OpenApp(UCIAppName.Sales); - - xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); - - xrmApp.CommandBar.ClickCommand("New"); - xrmApp.ThinkTime(2000); - } + _xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); + _xrmApp.CommandBar.ClickCommand("New"); + _xrmApp.ThinkTime(2000); } [TestMethod] public void UCITestRetrieveCommandBarValues() { - var client = new WebClient(TestSettings.Options); - using (var xrmApp = new XrmApp(client)) - { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); - - xrmApp.Navigation.OpenApp(UCIAppName.Sales); - - xrmApp.Navigation.OpenSubArea("Sales", "Accounts"); - - var commandValues = xrmApp.CommandBar.GetCommandValues().Value; - int commandCount = commandValues.Count; - - var includeMoreCommandValues = xrmApp.CommandBar.GetCommandValues(true).Value; - int totalCommandCount = includeMoreCommandValues.Count; + var commandValues = _xrmApp.CommandBar.GetCommandValues().Value; + int commandCount = commandValues.Count; - xrmApp.ThinkTime(2000); + var includeMoreCommandValues = _xrmApp.CommandBar.GetCommandValues(true).Value; + int totalCommandCount = includeMoreCommandValues.Count; - } + _xrmApp.ThinkTime(2000); } } } \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/DuplicateDetection.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/DuplicateDetection.cs index a905111f..10db29e0 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/DuplicateDetection.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/DuplicateDetection.cs @@ -2,42 +2,32 @@ // Licensed under the MIT license. using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class DuplicateDetectionUCI + public class DuplicateDetection : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); + [TestInitialize] + public override void InitTest() => base.InitTest(); + [TestCleanup] + public override void FinishTest() => base.FinishTest(); + + public override void NavigateToHomePage() => _xrmApp.Navigation.OpenSubArea("Sales", "Contacts"); [TestMethod] public void UCITestDuplicateDetection() { - var client = new WebClient(TestSettings.Options); - using (var xrmApp = new XrmApp(client)) - { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); - - xrmApp.Navigation.OpenApp(UCIAppName.Sales); - - xrmApp.Navigation.OpenSubArea("Sales", "Contacts"); - - xrmApp.CommandBar.ClickCommand("New"); + _xrmApp.Navigation.OpenSubArea("Sales", "Contacts"); - xrmApp.Entity.SetValue("firstname", "EasyRepro"); - xrmApp.Entity.SetValue("lastname", "Duplicate"); - xrmApp.Entity.SetValue("emailaddress1", "jz3@jztest.com"); + _xrmApp.CommandBar.ClickCommand("New"); - xrmApp.Entity.Save(); + _xrmApp.Entity.SetValue("firstname", "EasyRepro"); + _xrmApp.Entity.SetValue("lastname", "Duplicate"); + _xrmApp.Entity.SetValue("emailaddress1", "jz3@jztest.com"); - } + _xrmApp.Entity.Save(); } } } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/SelectDashboard.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/SelectDashboard.cs index 4c714cf3..123fb493 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/SelectDashboard.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/CommandBar/SelectDashboard.cs @@ -2,35 +2,24 @@ // Licensed under the MIT license. using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class SelectDashboardUCI + public class SelectDashboard : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); + [TestInitialize] + public override void InitTest() => base.InitTest(); + + [TestCleanup] + public override void FinishTest() => base.FinishTest(); [TestMethod] public void UCITestSelectDashboard() { - var client = new WebClient(TestSettings.Options); - using (var xrmApp = new XrmApp(client)) - { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); - - xrmApp.Navigation.OpenApp(UCIAppName.Sales); - - xrmApp.Navigation.ClickQuickLaunchButton("Dashboards"); - - xrmApp.Dashboard.SelectDashboard("My Knowledge Dashboard"); + _xrmApp.Navigation.ClickQuickLaunchButton("Dashboards"); - } + _xrmApp.Dashboard.SelectDashboard("My Knowledge Dashboard"); } } } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Controls/Grid.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Controls/Grid.cs index 19c150e6..4569f5ab 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Controls/Grid.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Controls/Grid.cs @@ -10,7 +10,7 @@ namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class Grid + public class Grid : TestsBase { private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); @@ -23,7 +23,7 @@ public void UCIGridSort() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateActivity.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateActivity.cs index cd91b89a..97941bb7 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateActivity.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateActivity.cs @@ -3,29 +3,20 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using System; -using System.Globalization; -using System.Security; -using Microsoft.Dynamics365.UIAutomation.Api.UCI; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class CreateActivityUCI + public class CreateActivityUCI : TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestCreateActivity_SetDateTimes() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateCase.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateCase.cs index b7065465..35a5b6d3 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateCase.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateCase.cs @@ -3,28 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class CreateCaseUCI + public class CreateCaseUCI : TestsBase { - - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestCreateCase() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); @@ -41,7 +32,6 @@ public void UCITestCreateCase() xrmApp.Entity.Save(); } - } } } \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateContact.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateContact.cs index 4d6dc3cf..32c0427c 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateContact.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateContact.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class CreateContactUCI + public class CreateContactUCI : TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestCreateContact() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateLead.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateLead.cs index 403720b7..dda15451 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateLead.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateLead.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class CreateLeadUCI + public class CreateLeadUCI: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestCreateLead() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -38,9 +30,7 @@ public void UCITestCreateLead() xrmApp.Entity.SetValue("lastname", TestSettings.GetRandomString(5,10)); xrmApp.Entity.Save(); - } - } } } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateOpportunity.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateOpportunity.cs index 2fa7fdde..cb3c65c8 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateOpportunity.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateOpportunity.cs @@ -1,29 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class CreateOpportunityUCI + public class CreateOpportunityUCI : TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestCreateOpportunity() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteAccount.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteAccount.cs index b9d3ab97..0d82ba91 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteAccount.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteAccount.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class DeleteAccountUCI + public class DeleteAccountUCI : TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestDeleteAccount() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteCase.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteCase.cs index 2e1286a5..66e8608f 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteCase.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteCase.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class DeleteCaseUCI + public class DeleteCaseUCI : TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestDeleteCase() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); @@ -37,9 +29,7 @@ public void UCITestDeleteCase() xrmApp.Dialogs.ConfirmationDialog(true); //Click OK on the Delete confirmation dialog (false to cancel) xrmApp.ThinkTime(3000); - } - } } } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteContact.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteContact.cs index f4beade3..cd7d5e58 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteContact.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteContact.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class DeleteContactUCI + public class DeleteContactUCI : TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestDeleteContact() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteLead.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteLead.cs index 766f6292..b1a55fe8 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteLead.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteLead.cs @@ -3,27 +3,20 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class DeleteLeadUCI + public class DeleteLeadUCI : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestDeleteLead() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteOpportunity.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteOpportunity.cs index f46de213..9e860db4 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteOpportunity.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Delete/DeleteOpportunity.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class DeleteOpportunityUCI + public class DeleteOpportunityUCI : TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestDeleteOpportunity() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GetValue.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GetValue.cs index 5702dade..0d5e2fc8 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GetValue.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GetValue.cs @@ -3,26 +3,20 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class GetValueUci + public class GetValueUci: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestGetValueFromOptionSet() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -41,7 +35,7 @@ public void UCITestGetValueFromLookup() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -60,7 +54,7 @@ public void UCITestActivityPartyGetValue() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -83,7 +77,7 @@ public void UCITestGetValueFromDateTime() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GlobalSearch/GlobalCategorizedSearch.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GlobalSearch/GlobalCategorizedSearch.cs index ecb83694..0b97c0ac 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GlobalSearch/GlobalCategorizedSearch.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GlobalSearch/GlobalCategorizedSearch.cs @@ -3,26 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class GlobalCategorizedSearchUci + public class GlobalCategorizedSearchUci : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"]); - [TestMethod] public void UCITestGlobalCategorizedSearch() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GlobalSearch/GlobalRelevanceSearch.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GlobalSearch/GlobalRelevanceSearch.cs index 8abe9d36..ec6ebc56 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GlobalSearch/GlobalRelevanceSearch.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/GlobalSearch/GlobalRelevanceSearch.cs @@ -3,26 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class GlobalRelevanceSearchUci + public class GlobalRelevanceSearchUci: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"]); - [TestMethod] public void UCITestGlobalRelevanceSearch() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/FormSelector.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/FormSelector.cs index 258b9fce..0f4837f5 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/FormSelector.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/FormSelector.cs @@ -3,26 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class FormSelectorUci + public class FormSelectorUci: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"]); - [TestMethod] public void UCITestOpenGlobalSearchSelectForm() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/GlobalSearch.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/GlobalSearch.cs index a3f9602b..98214af4 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/GlobalSearch.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/GlobalSearch.cs @@ -3,26 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class OpenGlobalSearchUci + public class OpenGlobalSearchUci: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"]); - [TestMethod] public void UCITestOpenGlobalSearch() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); xrmApp.Navigation.OpenGlobalSearch(); } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/OpenNavigation.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/OpenNavigation.cs index 9a2d8f13..beac3bed 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/OpenNavigation.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/OpenNavigation.cs @@ -3,26 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class OpenNavigationUci + public class OpenNavigationUci: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"]); - [TestMethod] public void UCITestOpenOptions() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); xrmApp.Navigation.OpenOptions(); xrmApp.Navigation.OpenOptInForLearningPath(); @@ -37,7 +30,7 @@ public void UCITestOpenGuidedHelp() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); xrmApp.Navigation.OpenGuidedHelp(); } @@ -49,7 +42,7 @@ public void UCITestOpenSoftwareLicensing() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); xrmApp.Navigation.OpenSoftwareLicensing(); } @@ -61,7 +54,7 @@ public void UCITestOpenToastNotifications() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); xrmApp.Navigation.OpenToastNotifications(); } @@ -72,7 +65,7 @@ public void UCITestOpenAbout() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); xrmApp.Navigation.OpenAbout(); } @@ -84,7 +77,7 @@ public void UCITestOpenRelatedCommonActivities() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -102,7 +95,7 @@ public void UCITestOpenGroupSubArea() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/PortalAdmin.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/PortalAdmin.cs index 84631116..4f04f31b 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/PortalAdmin.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Navigation/PortalAdmin.cs @@ -3,26 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class PortalAdminUci + public class PortalAdminUci: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"]); - [TestMethod] public void UCITestOpenPortalAdmin() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); xrmApp.Navigation.OpenPortalAdmin(); } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/QuickCreate/QuickCreate.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/QuickCreate/QuickCreate.cs index 6f5357d8..ea930aee 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/QuickCreate/QuickCreate.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/QuickCreate/QuickCreate.cs @@ -2,26 +2,20 @@ // Licensed under the MIT license. using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class QuickCreateContactUCI + public class QuickCreateContactUCI: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestQuickCreateContact() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -44,7 +38,7 @@ public void UCITestQuickCreateCase() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); @@ -67,7 +61,7 @@ public void UCITestQuickCreateOpportunity() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/HighlightAccount.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/HighlightAccount.cs index e7d47a27..f0f819d7 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/HighlightAccount.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/HighlightAccount.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class HighlightAccount + public class HighlightAccount: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestHighlightActiveAccount() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenAccount.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenAccount.cs index c9ff47c7..8b9b01da 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenAccount.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenAccount.cs @@ -3,27 +3,20 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class OpenAccountUCI + public class OpenAccountUCI: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestOpenActiveAccount() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -44,7 +37,7 @@ public void UCITestGetActiveGridItems() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -64,7 +57,7 @@ public void UCITestOpenTabDetails() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -91,7 +84,7 @@ public void UCITestGetObjectId() using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -112,7 +105,7 @@ public void UCITestOpenSubGridRecord() using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenCase.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenCase.cs index 47effe9f..21a56de9 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenCase.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenCase.cs @@ -3,26 +3,20 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class OpenCaseUCI + public class OpenCaseUCI: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestOpenActiveCase() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); @@ -40,7 +34,7 @@ public void UCITestOpenCase() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); @@ -61,7 +55,7 @@ public void UCITestOpenCaseById() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); @@ -80,7 +74,7 @@ public void UCITestOpenCaseRetrieveHeaderValues() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenContact.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenContact.cs index 175377d9..d4bdee09 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenContact.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenContact.cs @@ -3,28 +3,20 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; using System.Collections.Generic; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class OpenContactUCI + public class OpenContactUCI: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestOpenActiveContact() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -44,7 +36,7 @@ public void UCITestOpenRecordSetNavigator() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -74,7 +66,7 @@ public void UCITestOpenSubGridRecord() using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -99,7 +91,7 @@ public void UCITestLookupSearch() using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -127,7 +119,7 @@ public void UCITestLookupNew() using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -155,7 +147,7 @@ public void UCITestOpenContactRetrieveHeaderValues() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); @@ -179,7 +171,7 @@ public void UCITestOpenContactRelatedEntity() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenLead.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenLead.cs index efa85434..e8f99c50 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenLead.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenLead.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class OpenLeadUCI + public class OpenLeadUCI: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestOpenActiveLead() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -43,7 +35,7 @@ public void UCITestRetrieveBPFFields() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -72,7 +64,7 @@ public void UCITestPinBPFStage() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -94,7 +86,7 @@ public void UCITestCloseBPFStage() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenOpportunity.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenOpportunity.cs index 14faec90..0c4e5c62 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenOpportunity.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Read/OpenOpportunity.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class OpenOpportunityUCI + public class OpenOpportunityUCI: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestOpenActiveOpportunity() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -43,7 +35,7 @@ public void UCITestOpenOpportunityLookupAccount() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -66,7 +58,7 @@ public void UCITestOpenOpportunitySearchLookupAccount() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/SetValue.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/SetValue.cs index 376e8e22..89e4c413 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/SetValue.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/SetValue.cs @@ -3,26 +3,20 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class SetValueUci + public class SetValueUci : TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestSetValue() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -42,7 +36,7 @@ public void UCITestSelectOptionSetValue() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -62,7 +56,7 @@ public void UCITestOpenLookupSetValue() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -84,7 +78,7 @@ public void UCITestActivityPartySetValue() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -115,7 +109,7 @@ public void UCITestActivityPartyAddValues() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -142,7 +136,7 @@ public void UCITestActivityPartyRemoveValues() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -169,7 +163,7 @@ public void UCITestActivityClearValues() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -195,7 +189,7 @@ public void UCITestDateTimeSetValue() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/SpecialConfigurationTests/RandomAccountTest.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/SpecialConfigurationTests/RandomAccountTest.cs index 0989371d..d677017f 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/SpecialConfigurationTests/RandomAccountTest.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/SpecialConfigurationTests/RandomAccountTest.cs @@ -3,20 +3,12 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; -using System.Text; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class RandomAccountTest + public class RandomAccountTest: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCIRandomAccountTest() { @@ -24,7 +16,7 @@ public void UCIRandomAccountTest() using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddActivity.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddActivity.cs index 88f5984a..e7d79238 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddActivity.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddActivity.cs @@ -1,25 +1,18 @@ using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class AddActivity + public class AddActivity: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestAccountAddAppointment() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -41,7 +34,7 @@ public void UCITestAccountAddEmail() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -81,7 +74,7 @@ public void UCITestAccountGetMultiSelectEmail() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -125,7 +118,7 @@ public void UCITestAccountRemoveMultiSelectEmail() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -161,7 +154,7 @@ public void UCITestAccountAddPhoneCall() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -183,7 +176,7 @@ public void UCITestAccountAddTask() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddNote.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddNote.cs index 2ccf660e..b91894d7 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddNote.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddNote.cs @@ -1,25 +1,18 @@ using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class AddNote + public class AddNote: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestAccountAddNote() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddPost.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddPost.cs index 17f3a8f9..583ef928 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddPost.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Timeline/AddPost.cs @@ -1,25 +1,18 @@ using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class AddPostUCI + public class AddPostUCI: TestsBase { - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestAccountAddPost() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateAccount.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateAccount.cs index 5f4548d8..6fe49632 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateAccount.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateAccount.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class UpdateAccountUCI + public class UpdateAccountUCI: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestUpdateActiveAccount() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateCase.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateCase.cs index 650f2ec8..c9a90667 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateCase.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateCase.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class UpdateCaseUCI + public class UpdateCaseUCI : TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestUpdateActiveCase() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); @@ -47,7 +39,7 @@ public void UCITestUpdateActiveCaseSetHeaderValues() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateContact.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateContact.cs index d6bd02d7..cd64ab14 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateContact.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateContact.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class UpdateContactUCI + public class UpdateContactUCI: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestUpdateActiveContact() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -48,7 +40,7 @@ public void UCITestUpdateActiveContactSetHeaderValues() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); @@ -72,7 +64,7 @@ public void UCITestUpdateClearFields() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.CustomerService); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateLead.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateLead.cs index 7974c345..8cf7f33e 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateLead.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateLead.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class UpdateLeadUCI + public class UpdateLeadUCI: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestUpdateActiveLead() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -47,7 +39,7 @@ public void UCITestOpenActiveLeadBPF() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateOpportunity.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateOpportunity.cs index a22dd8d1..c4152b7b 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateOpportunity.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Update/UpdateOpportunity.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class UpdateOpportunityUCI + public class UpdateOpportunityUCI: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestUpdateActiveOpportunity() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Validate/CheckFieldRequired.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Validate/CheckFieldRequired.cs index db8fecb6..60dfcce5 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Validate/CheckFieldRequired.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Validate/CheckFieldRequired.cs @@ -3,27 +3,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; -using Microsoft.Dynamics365.UIAutomation.Browser; -using System; -using System.Security; namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] - public class IsFieldRequired + public class IsFieldRequired: TestsBase { - - private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString(); - private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString(); - private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString()); - [TestMethod] public void UCITestConfirmFieldIsNotRequired() { var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); @@ -48,7 +40,7 @@ public void UCITestConfirmFieldIsRequired() var client = new WebClient(TestSettings.Options); using (var xrmApp = new XrmApp(client)) { - xrmApp.OnlineLogin.Login(_xrmUri, _username, _password); + xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecrectKey); xrmApp.Navigation.OpenApp(UCIAppName.Sales); From 8a578a4e5ae0baa3b60dcbca4fe53e8be260395d Mon Sep 17 00:00:00 2001 From: "Angel A. Rodriguez" Date: Thu, 23 Jan 2020 11:39:03 +0100 Subject: [PATCH 3/7] Rebuild Ordered Tests --- .../UCI/UnifiedInterface.orderedtest | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/UnifiedInterface.orderedtest b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/UnifiedInterface.orderedtest index 60329209..9635b9ad 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/UnifiedInterface.orderedtest +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/UnifiedInterface.orderedtest @@ -1,7 +1,7 @@  - + - + @@ -14,17 +14,15 @@ - - - - + + + + - - + - @@ -40,10 +38,10 @@ - + - + From 8c2452d89f5b70bfe846500563abc33765bf3a58 Mon Sep 17 00:00:00 2001 From: "Angel A. Rodriguez" Date: Thu, 23 Jan 2020 11:55:57 +0100 Subject: [PATCH 4/7] Merge branch 'users/angel/addDriversPathToAppConfig' into users/angel/addMFA # Conflicts: # Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs # Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateOpportunity.cs # Microsoft.Dynamics365.UIAutomation.Sample/UCI/UnifiedInterface.orderedtest --- ...Microsoft.Dynamics365.UIAutomation.Sample.csproj | 1 + .../TestSettings.cs | 13 +++++++++---- .../UCI/Create/CreateOpportunity.cs | 1 - .../app.build.config | 10 ++++++++++ .../app.config | 2 ++ 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 Microsoft.Dynamics365.UIAutomation.Sample/app.build.config diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj b/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj index 4615f1f1..2b503ebf 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj @@ -226,6 +226,7 @@ + Designer diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs b/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs index 1b48ea88..d869275b 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs @@ -3,6 +3,8 @@ using Microsoft.Dynamics365.UIAutomation.Api; using Microsoft.Dynamics365.UIAutomation.Browser; using System; +using System.Configuration; +using System.IO; namespace Microsoft.Dynamics365.UIAutomation.Sample { @@ -13,14 +15,16 @@ public static class TestSettings public static LookupItem LookupValues = new LookupItem { Name = "primarycontactid", Value = "Nancy Anderson (sample)" } ; public static string LookupField = "primarycontactid"; public static string LookupName = "Nancy Anderson (sample)"; - private static readonly string Type = System.Configuration.ConfigurationManager.AppSettings["BrowserType"].ToString(); - private static readonly string RemoteType = System.Configuration.ConfigurationManager.AppSettings["RemoteBrowserType"].ToString(); - private static readonly string RemoteHubServerURL = System.Configuration.ConfigurationManager.AppSettings["RemoteHubServer"].ToString(); + private static readonly string Type = ConfigurationManager.AppSettings["BrowserType"]; + private static readonly string RemoteType = ConfigurationManager.AppSettings["RemoteBrowserType"]; + private static readonly string RemoteHubServerURL = ConfigurationManager.AppSettings["RemoteHubServer"]; + private static readonly string DriversPath = ConfigurationManager.AppSettings["DriversPath"]; + private static readonly bool? UsePrivateMode = Convert.ToBoolean(ConfigurationManager.AppSettings["UsePrivateMode"]); public static BrowserOptions Options = new BrowserOptions { BrowserType = (BrowserType)Enum.Parse(typeof(BrowserType), Type), - PrivateMode = true, + PrivateMode = UsePrivateMode ?? true, FireEvents = false, Headless = false, UserAgent = false, @@ -29,6 +33,7 @@ public static class TestSettings RemoteHubServer = new Uri(RemoteHubServerURL), UCITestMode = true, UCIPerformanceMode = false + DriversPath = Path.IsPathRooted(DriversPath) ? DriversPath : Path.Combine(Directory.GetCurrentDirectory(), DriversPath) }; public static string GetRandomString(int minLen, int maxLen) diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateOpportunity.cs b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateOpportunity.cs index cb3c65c8..960fc04a 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateOpportunity.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/UCI/Create/CreateOpportunity.cs @@ -28,7 +28,6 @@ public void UCITestCreateOpportunity() xrmApp.Entity.SetValue("name", TestSettings.GetRandomString(5,10)); xrmApp.Entity.Save(); - } } diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/app.build.config b/Microsoft.Dynamics365.UIAutomation.Sample/app.build.config new file mode 100644 index 00000000..e939bf18 --- /dev/null +++ b/Microsoft.Dynamics365.UIAutomation.Sample/app.build.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/app.config b/Microsoft.Dynamics365.UIAutomation.Sample/app.config index 4c456982..da6a2e05 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/app.config +++ b/Microsoft.Dynamics365.UIAutomation.Sample/app.config @@ -18,6 +18,8 @@ + + From 69535e261aaf88f071e0198421e8584dc65d7293 Mon Sep 17 00:00:00 2001 From: "Angel A. Rodriguez" Date: Thu, 23 Jan 2020 12:33:06 +0100 Subject: [PATCH 5/7] Fix Build --- Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs b/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs index d869275b..9d967d31 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs @@ -32,7 +32,7 @@ public static class TestSettings RemoteBrowserType = (BrowserType)Enum.Parse(typeof(BrowserType), RemoteType), RemoteHubServer = new Uri(RemoteHubServerURL), UCITestMode = true, - UCIPerformanceMode = false + UCIPerformanceMode = false, DriversPath = Path.IsPathRooted(DriversPath) ? DriversPath : Path.Combine(Directory.GetCurrentDirectory(), DriversPath) }; From e8d78bc478ba9d50bdda40cb40e57d68398d302d Mon Sep 17 00:00:00 2001 From: "Angel A. Rodriguez" Date: Sat, 25 Jan 2020 01:09:06 +0100 Subject: [PATCH 6/7] Fix app.config --- Microsoft.Dynamics365.UIAutomation.Sample/app.config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/app.config b/Microsoft.Dynamics365.UIAutomation.Sample/app.config index 325c5e77..00b38be1 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/app.config +++ b/Microsoft.Dynamics365.UIAutomation.Sample/app.config @@ -11,10 +11,10 @@ - - - - + + + + From 633761eed974f0336c835779524d4b591abdef6b Mon Sep 17 00:00:00 2001 From: "Angel A. Rodriguez" Date: Mon, 27 Jan 2020 00:49:28 +0100 Subject: [PATCH 7/7] Fix DriversPath & UsePrivateMode Default Values --- Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs b/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs index 54da41d1..4c35b0bd 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs +++ b/Microsoft.Dynamics365.UIAutomation.Sample/TestSettings.cs @@ -18,13 +18,13 @@ public static class TestSettings private static readonly string Type = ConfigurationManager.AppSettings["BrowserType"]; private static readonly string RemoteType = ConfigurationManager.AppSettings["RemoteBrowserType"]; private static readonly string RemoteHubServerURL = ConfigurationManager.AppSettings["RemoteHubServer"]; - private static readonly string DriversPath = ConfigurationManager.AppSettings["DriversPath"]; - private static readonly bool? UsePrivateMode = Convert.ToBoolean(ConfigurationManager.AppSettings["UsePrivateMode"]); + private static readonly string DriversPath = ConfigurationManager.AppSettings["DriversPath"] ?? string.Empty; + private static readonly bool UsePrivateMode = Convert.ToBoolean(ConfigurationManager.AppSettings["UsePrivateMode"] ?? "true"); public static BrowserOptions Options = new BrowserOptions { BrowserType = (BrowserType)Enum.Parse(typeof(BrowserType), Type), - PrivateMode = UsePrivateMode ?? true, + PrivateMode = UsePrivateMode, FireEvents = false, Headless = false, UserAgent = false,