From fdda08b56b3ee1aa0e1f9e91dc3ff248df2728bb Mon Sep 17 00:00:00 2001 From: Leonid Netrebskii Date: Wed, 26 Oct 2022 23:34:47 +0400 Subject: [PATCH 1/8] Migrated to .NET 6: 1. Updated dependencies. 2. Removed the option "UseLegacyImplementation" because it is deprecated starting WebDriver 4.3 (see also https://www.selenium.dev/blog/2022/legacy-protocol-support/) 3. EdgeOptions setup adjusted to the updated package. --- .../Elements/Telemetry.cs | 2 +- ...ft.Dynamics365.UIAutomation.Api.UCI.csproj | 139 ++------- .../packages.config | 12 - ...rosoft.Dynamics365.UIAutomation.Api.csproj | 132 +------- .../Pages/PerformanceCenter.cs | 4 +- .../packages.config | 8 - .../BrowserOptions.cs | 7 +- .../DynamicJsonConverter.cs | 2 +- .../Extensions/SeleniumExtensions.cs | 16 +- ...ft.Dynamics365.UIAutomation.Browser.csproj | 115 +------ .../packages.config | 8 - ...oft.Dynamics365.UIAutomation.Sample.csproj | 295 ++---------------- .../packages.config | 15 - 13 files changed, 77 insertions(+), 678 deletions(-) delete mode 100644 Microsoft.Dynamics365.UIAutomation.Api.UCI/packages.config delete mode 100644 Microsoft.Dynamics365.UIAutomation.Api/packages.config delete mode 100644 Microsoft.Dynamics365.UIAutomation.Browser/packages.config delete mode 100644 Microsoft.Dynamics365.UIAutomation.Sample/packages.config diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Telemetry.cs b/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Telemetry.cs index be2609be..53945a4a 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Telemetry.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Telemetry.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Web.Script.Serialization; +using Nancy; using Newtonsoft.Json; using Microsoft.ApplicationInsights.DataContracts; 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 89c15206..31078abc 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 @@ -1,135 +1,32 @@ - - - + - Debug - AnyCPU - {AFCB5BB5-4512-4019-A911-5D56CFF4F3D0} Library - Properties - Microsoft.Dynamics365.UIAutomation.Api.UCI - Microsoft.Dynamics365.UIAutomation.Api.UCI - v4.6 - 512 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - 7.2 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + + net6.0 + false 7.2 - - ..\packages\Microsoft.ApplicationInsights.2.11.0\lib\net46\Microsoft.ApplicationInsights.dll - - - ..\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 - - - - ..\packages\System.Diagnostics.DiagnosticSource.4.6.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - - ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll - - - - - - - - - - - ..\packages\Selenium.WebDriver.3.141.0\lib\net45\WebDriver.dll - - - ..\packages\Selenium.Support.3.141.0\lib\net45\WebDriver.Support.dll - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + + + + + + - - {dfe2c141-f1aa-4d4b-8df8-0fb93023cf45} - Microsoft.Dynamics365.UIAutomation.Api - - - {c9748803-f3cb-4531-b313-bc24d4d0bf0c} - Microsoft.Dynamics365.UIAutomation.Browser - + - - \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/packages.config b/Microsoft.Dynamics365.UIAutomation.Api.UCI/packages.config deleted file mode 100644 index 10664e4d..00000000 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj b/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj index 1a440f8a..236186bc 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj @@ -1,136 +1,26 @@ - - - + - Debug - AnyCPU - {DFE2C141-F1AA-4D4B-8DF8-0FB93023CF45} - Library - Properties - Microsoft.Dynamics365.UIAutomation.Api - Microsoft.Dynamics365.UIAutomation.Api - v4.6 - 512 - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - 7.2 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + net6.0 + false 7.2 - - false - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - - - - - ..\packages\Selenium.WebDriver.3.141.0\lib\net45\WebDriver.dll - - - ..\packages\Selenium.Support.3.141.0\lib\net45\WebDriver.Support.dll - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - Designer - + + + - - {c9748803-f3cb-4531-b313-bc24d4d0bf0c} - Microsoft.Dynamics365.UIAutomation.Browser - + - - - \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Api/Pages/PerformanceCenter.cs b/Microsoft.Dynamics365.UIAutomation.Api/Pages/PerformanceCenter.cs index e4b411d9..217ec0ca 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api/Pages/PerformanceCenter.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api/Pages/PerformanceCenter.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using Nancy.Json; using Microsoft.Dynamics365.UIAutomation.Browser; using Newtonsoft.Json.Linq; using OpenQA.Selenium; @@ -8,7 +9,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Web.Script.Serialization; namespace Microsoft.Dynamics365.UIAutomation.Api { @@ -110,7 +110,7 @@ public BrowserCommandResult> GetMarkersRaw() jsSerializer.RegisterConverters(new[] { new DynamicJsonConverter() }); - var jsonObj = (Dictionary)jsSerializer.Deserialize(jsonResults, typeof(Dictionary)); + var jsonObj = (Dictionary)jsSerializer.Deserialize>(jsonResults); return jsonObj; }); diff --git a/Microsoft.Dynamics365.UIAutomation.Api/packages.config b/Microsoft.Dynamics365.UIAutomation.Api/packages.config deleted file mode 100644 index 2c229364..00000000 --- a/Microsoft.Dynamics365.UIAutomation.Api/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/BrowserOptions.cs b/Microsoft.Dynamics365.UIAutomation.Browser/BrowserOptions.cs index cda6874f..76f077f4 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/BrowserOptions.cs +++ b/Microsoft.Dynamics365.UIAutomation.Browser/BrowserOptions.cs @@ -252,10 +252,7 @@ public virtual InternetExplorerOptions ToInternetExplorer() public virtual FirefoxOptions ToFireFox() { - var options = new FirefoxOptions() - { - UseLegacyImplementation = false - }; + var options = new FirefoxOptions(); if (!string.IsNullOrEmpty(DownloadsPath)) { @@ -273,8 +270,8 @@ public virtual EdgeOptions ToEdge() var options = new EdgeOptions() { PageLoadStrategy = PageLoadStrategy.Normal, - UseInPrivateBrowsing = PrivateMode }; + options.AddArgument("inprivate"); return options; } diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/DynamicJsonConverter.cs b/Microsoft.Dynamics365.UIAutomation.Browser/DynamicJsonConverter.cs index 2a6f8e75..d24dabea 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/DynamicJsonConverter.cs +++ b/Microsoft.Dynamics365.UIAutomation.Browser/DynamicJsonConverter.cs @@ -8,7 +8,7 @@ using System.Dynamic; using System.Linq; using System.Text; -using System.Web.Script.Serialization; +using Nancy.Json; namespace Microsoft.Dynamics365.UIAutomation.Browser { diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs b/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs index 89aeae84..d1985d96 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs @@ -1,11 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using Nancy.Json; using Newtonsoft.Json.Linq; using OpenQA.Selenium; using OpenQA.Selenium.Interactions; using OpenQA.Selenium.Support.Events; using OpenQA.Selenium.Support.UI; +using SeleniumExtras.WaitHelpers; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -14,7 +16,6 @@ using System.Drawing; using System.IO; using System.Linq; -using System.Web.Script.Serialization; namespace Microsoft.Dynamics365.UIAutomation.Browser { @@ -195,19 +196,6 @@ public static Screenshot TakeScreenshot(this IWebDriver driver) return screenshotDriver.GetScreenshot(); } - [DebuggerNonUserCode] - public static Bitmap TakeScreenshot(this IWebDriver driver, By by) - { - var screenshot = TakeScreenshot(driver); - var bmpScreen = new Bitmap(new MemoryStream(screenshot.AsByteArray)); - - // Measure the location of a specific element - IWebElement element = driver.FindElement(by); - var crop = new Rectangle(element.Location, element.Size); - - return bmpScreen.Clone(crop, bmpScreen.PixelFormat); - } - #endregion Screenshot #region Elements diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj index 0808752a..85c2e0db 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj @@ -1,119 +1,36 @@ - - - + - Debug - AnyCPU - {C9748803-F3CB-4531-B313-BC24D4D0BF0C} - Library - Properties - Microsoft.Dynamics365.UIAutomation.Browser - Microsoft.Dynamics365.UIAutomation.Browser - v4.6 - 512 - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - 7.2 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + net6.0 + false 7.2 - - false - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - - - - ..\packages\Selenium.WebDriver.3.141.0\lib\net45\WebDriver.dll - - - ..\packages\Selenium.Support.3.141.0\lib\net45\WebDriver.Support.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Resources.resx True True - - - - + + + - + ResXFileCodeGenerator Resources.Designer.cs - - + + + + + + + + \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/packages.config b/Microsoft.Dynamics365.UIAutomation.Browser/packages.config deleted file mode 100644 index 2abb7554..00000000 --- a/Microsoft.Dynamics365.UIAutomation.Browser/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj b/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj index f218872b..0c93489b 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj @@ -1,273 +1,42 @@ - - + - Debug - AnyCPU - {A075B87E-DCA5-4A2A-909B-932E2F5F98B4} - Library - Properties - Microsoft.Dynamics365.UIAutomation.Sample - Microsoft.Dynamics365.UIAutomation.Sample - v4.6 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - 7.2 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + net6.0 + false 7.2 - - - ..\packages\Microsoft.ApplicationInsights.2.11.0\lib\net46\Microsoft.ApplicationInsights.dll - - - ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - True - - - - ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll - - - - ..\packages\System.Diagnostics.DiagnosticSource.4.6.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - - ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll - - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll - - - - ..\packages\Selenium.WebDriver.3.141.0\lib\net45\WebDriver.dll - - - ..\packages\Selenium.Support.3.141.0\lib\net45\WebDriver.Support.dll - - - - - - False - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - Designer - - - - Designer - - - + + + + + + + + + + + + + + + - - - {afcb5bb5-4512-4019-a911-5d56cff4f3d0} - Microsoft.Dynamics365.UIAutomation.Api.UCI - - - {dfe2c141-f1aa-4d4b-8df8-0fb93023cf45} - Microsoft.Dynamics365.UIAutomation.Api - - - {c9748803-f3cb-4531-b313-bc24d4d0bf0c} - Microsoft.Dynamics365.UIAutomation.Browser - + + @@ -287,22 +56,6 @@ - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/packages.config b/Microsoft.Dynamics365.UIAutomation.Sample/packages.config deleted file mode 100644 index 13fc49ab..00000000 --- a/Microsoft.Dynamics365.UIAutomation.Sample/packages.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file From 3bd6a6db3e99e4ddc8fac9dde8daa2116cd9317a Mon Sep 17 00:00:00 2001 From: Leonid Netrebskii Date: Thu, 17 Nov 2022 16:23:07 +0400 Subject: [PATCH 2/8] Add copy and rename of the app.config --- ...oft.Dynamics365.UIAutomation.Sample.csproj | 3 + .../app.config | 55 ------------------- 2 files changed, 3 insertions(+), 55 deletions(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj b/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj index 0c93489b..af511ac1 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Sample/Microsoft.Dynamics365.UIAutomation.Sample.csproj @@ -38,6 +38,9 @@ + + + diff --git a/Microsoft.Dynamics365.UIAutomation.Sample/app.config b/Microsoft.Dynamics365.UIAutomation.Sample/app.config index c2d7bc7a..02036891 100644 --- a/Microsoft.Dynamics365.UIAutomation.Sample/app.config +++ b/Microsoft.Dynamics365.UIAutomation.Sample/app.config @@ -2,18 +2,6 @@ - - - - - - - - - - - - @@ -28,47 +16,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 02a0e1f9d8f85d1de580c74156d4f78b3f56de12 Mon Sep 17 00:00:00 2001 From: Leonid Netrebskii Date: Thu, 27 Oct 2022 09:06:25 +0400 Subject: [PATCH 3/8] Get rid of unnecessary dependency Microsoft.Win32.Registry --- .../Microsoft.Dynamics365.UIAutomation.Browser.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj index 85c2e0db..49c2582f 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj @@ -31,6 +31,5 @@ - \ No newline at end of file From b846d6d66188e3a49118e83ca00b0ea580f88eb9 Mon Sep 17 00:00:00 2001 From: Leonid Netrebskii Date: Fri, 28 Oct 2022 11:29:15 +0400 Subject: [PATCH 4/8] Update from DotNetSeleniumExtras.WaitHelpers to SeleniumExtras.WaitHelpers to support WebDriver v.4 --- .../Microsoft.Dynamics365.UIAutomation.Browser.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj index 49c2582f..244c6fa5 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj @@ -15,8 +15,8 @@ - + From 6689d716527d6e05e0f9cfa4def67cf2bde82b08 Mon Sep 17 00:00:00 2001 From: Leonid Netrebskii Date: Fri, 28 Oct 2022 12:25:27 +0400 Subject: [PATCH 5/8] See https://learn.microsoft.com/en-us/answers/questions/302548/jsonserializer-throws-exception-in-xamarinios.html --- .../Microsoft.Dynamics365.UIAutomation.Api.UCI.csproj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 31078abc..8ce6779b 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 @@ -21,9 +21,13 @@ - - + + none + + + none + From 91be67f43a4b394c6373eb439cec8a3047c94c03 Mon Sep 17 00:00:00 2001 From: Leonid Netrebskii Date: Tue, 1 Nov 2022 23:05:20 +0400 Subject: [PATCH 6/8] Add support compiling of net462 version --- .../DynamicJsonConverter.cs | 4 ++ .../Extensions/SeleniumExtensions.cs | 38 ++++++++++--------- ...ft.Dynamics365.UIAutomation.Browser.csproj | 15 ++++++-- .../Properties/Resources.Designer.cs | 11 +++--- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/DynamicJsonConverter.cs b/Microsoft.Dynamics365.UIAutomation.Browser/DynamicJsonConverter.cs index d24dabea..a779a776 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/DynamicJsonConverter.cs +++ b/Microsoft.Dynamics365.UIAutomation.Browser/DynamicJsonConverter.cs @@ -8,7 +8,11 @@ using System.Dynamic; using System.Linq; using System.Text; +#if !NET462 using Nancy.Json; +#else +using System.Web.Script.Serialization; +#endif namespace Microsoft.Dynamics365.UIAutomation.Browser { diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs b/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs index d1985d96..d9c422de 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Extensions/SeleniumExtensions.cs @@ -1,13 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using Nancy.Json; using Newtonsoft.Json.Linq; using OpenQA.Selenium; using OpenQA.Selenium.Interactions; using OpenQA.Selenium.Support.Events; using OpenQA.Selenium.Support.UI; using SeleniumExtras.WaitHelpers; +#if !NET462 +using Nancy.Json; +#else +using System.Web.Script.Serialization; +#endif using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -21,7 +25,7 @@ namespace Microsoft.Dynamics365.UIAutomation.Browser { public static class SeleniumExtensions { - #region Click +#region Click public static void Click(this IWebElement element, bool ignoreStaleElementException) { @@ -71,12 +75,12 @@ public static void Hover(this IWebElement element, IWebDriver driver, bool ignor } } - #endregion Click +#endregion Click public static void Click(this IWebDriver driver, IWebElement element, Func offsetFunc = null, bool ignoreStaleElementException = true) => driver.Perform(a => a.Click(), element, offsetFunc, ignoreStaleElementException); - #region Double Click +#region Double Click public static void DoubleClick(this IWebDriver driver, IWebElement element, Func offsetFunc = null, bool ignoreStaleElementException = true) => driver.Perform(a => a.DoubleClick(), element, offsetFunc, ignoreStaleElementException); @@ -103,9 +107,9 @@ public static void Perform(this IWebDriver driver, Func action } - #endregion +#endregion - #region Script Execution +#region Script Execution [DebuggerNonUserCode] public static object ExecuteScript(this IWebDriver driver, string script, params object[] args) @@ -169,9 +173,9 @@ private static string SanitizeReturnStatement(string script) return script; } - #endregion Script Execution +#endregion Script Execution - #region Browser Options +#region Browser Options [DebuggerNonUserCode] public static void ResetZoom(this IWebDriver driver) @@ -180,9 +184,9 @@ public static void ResetZoom(this IWebDriver driver) element.SendKeys(Keys.Control + "0"); } - #endregion Browser Options +#endregion Browser Options - #region Screenshot +#region Screenshot [DebuggerNonUserCode] public static Screenshot TakeScreenshot(this IWebDriver driver) @@ -196,9 +200,9 @@ public static Screenshot TakeScreenshot(this IWebDriver driver) return screenshotDriver.GetScreenshot(); } - #endregion Screenshot +#endregion Screenshot - #region Elements +#region Elements public static bool HasAttribute(this IWebElement element, string attributeName) => element.GetAttribute(attributeName) != null; @@ -264,9 +268,9 @@ public static void ClearFocus(this IWebDriver driver) driver.FindElement(By.TagName("body")).Click(); } - #endregion Elements +#endregion Elements - #region Waits +#region Waits public static bool WaitForPageToLoad(this IWebDriver driver, TimeSpan? timeout = null) { @@ -622,9 +626,9 @@ public static bool RepeatUntil(this IWebDriver driver, Action action, Predicate< return success; } - #endregion Waits +#endregion Waits - #region Args / Tracing +#region Args / Tracing public static string ToTraceString(this FindElementEventArgs e) { @@ -645,6 +649,6 @@ public static string ToTraceString(this FindElementEventArgs e) return method; } - #endregion Args / Tracing +#endregion Args / Tracing } } \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj index 244c6fa5..c73ba6a0 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj @@ -1,6 +1,6 @@  - net6.0 + net6.0;net462 false 7.2 @@ -16,9 +16,19 @@ - + + + + + + + + + + + ResXFileCodeGenerator @@ -29,7 +39,6 @@ - \ No newline at end of file diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Properties/Resources.Designer.cs b/Microsoft.Dynamics365.UIAutomation.Browser/Properties/Resources.Designer.cs index 348d3562..1854006f 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Properties/Resources.Designer.cs +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.Dynamics365.UIAutomation.Browser.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -61,7 +61,10 @@ internal Resources() { } /// - /// Looks up a localized string similar to if (typeof (Recorder) === "undefined") { Recorder = { __namespace: true } } + /// Looks up a localized string similar to // Copyright (c) Microsoft Corporation. All rights reserved. + ///// Licensed under the MIT license. + /// + ///if (typeof (Recorder) === "undefined") { Recorder = { __namespace: true } } /// ///Recorder.ELEMENT_NODE = 1; /// @@ -71,9 +74,7 @@ internal Resources() { /// if (document.addEventListener) { /// document.addEventListener('mouseup', Recorder.clickHandler, false); /// document.addEventListener('keypress', Recorder.keyHandler, false); - /// document.addEventListener('change', Recorder.changeHandler, false); - /// } - /// else if ( [rest of string was truncated]";. + /// [rest of string was truncated]";. /// internal static string Recorder { get { From dd21b69b79767c33a9c34a1465e9960cde67da52 Mon Sep 17 00:00:00 2001 From: Leonid Netrebskii Date: Tue, 1 Nov 2022 23:13:37 +0400 Subject: [PATCH 7/8] Add net462 support to Api and Api.UCI --- .../Elements/Telemetry.cs | 6 +++++- .../Microsoft.Dynamics365.UIAutomation.Api.UCI.csproj | 6 +++++- .../Microsoft.Dynamics365.UIAutomation.Api.csproj | 8 +++++++- .../Pages/PerformanceCenter.cs | 4 ++++ .../Microsoft.Dynamics365.UIAutomation.Browser.csproj | 6 +++--- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Telemetry.cs b/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Telemetry.cs index 53945a4a..f91de07b 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Telemetry.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Telemetry.cs @@ -7,7 +7,11 @@ using System.Linq; using System.Collections.Generic; using System.Collections.ObjectModel; -using Nancy; +#if !NET462 +using Nancy.Json; +#else +using System.Web.Script.Serialization; +#endif using Newtonsoft.Json; using Microsoft.ApplicationInsights.DataContracts; 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 8ce6779b..d5765a1b 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 @@ -3,7 +3,7 @@ Library - net6.0 + net6.0;net462 false 7.2 @@ -30,6 +30,10 @@ + + + + diff --git a/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj b/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj index 236186bc..6097c906 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj @@ -1,6 +1,6 @@  - net6.0 + net6.0;net462 false 7.2 @@ -20,6 +20,12 @@ + + + + + + diff --git a/Microsoft.Dynamics365.UIAutomation.Api/Pages/PerformanceCenter.cs b/Microsoft.Dynamics365.UIAutomation.Api/Pages/PerformanceCenter.cs index 217ec0ca..6850c2c3 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api/Pages/PerformanceCenter.cs +++ b/Microsoft.Dynamics365.UIAutomation.Api/Pages/PerformanceCenter.cs @@ -1,7 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +#if !NET462 using Nancy.Json; +#else +using System.Web.Script.Serialization; +#endif using Microsoft.Dynamics365.UIAutomation.Browser; using Newtonsoft.Json.Linq; using OpenQA.Selenium; diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj index c73ba6a0..18cc67f8 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj @@ -23,11 +23,11 @@ - + - - + + From 67f59e03db8619fe5e3b63af6a2736dd0a086235 Mon Sep 17 00:00:00 2001 From: Leonid Netrebskii Date: Tue, 1 Nov 2022 23:18:13 +0400 Subject: [PATCH 8/8] Add netcoreapp3.1 support --- .../Microsoft.Dynamics365.UIAutomation.Api.UCI.csproj | 2 +- .../Microsoft.Dynamics365.UIAutomation.Api.csproj | 2 +- .../Microsoft.Dynamics365.UIAutomation.Browser.csproj | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) 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 d5765a1b..449d5b61 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 @@ -3,7 +3,7 @@ Library - net6.0;net462 + net6.0;net462;netcoreapp3.1 false 7.2 diff --git a/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj b/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj index 6097c906..8751200f 100644 --- a/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Api/Microsoft.Dynamics365.UIAutomation.Api.csproj @@ -1,6 +1,6 @@  - net6.0;net462 + net6.0;net462;netcoreapp3.1 false 7.2 diff --git a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj index 18cc67f8..0abcacc4 100644 --- a/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj +++ b/Microsoft.Dynamics365.UIAutomation.Browser/Microsoft.Dynamics365.UIAutomation.Browser.csproj @@ -1,6 +1,6 @@  - net6.0;net462 + net6.0;net462;netcoreapp3.1 false 7.2 @@ -29,6 +29,9 @@ + + + ResXFileCodeGenerator