From 6defcd52f3f61a39a5b5f678cb947c4ca974a870 Mon Sep 17 00:00:00 2001 From: leileizhang Date: Tue, 9 Sep 2025 09:17:17 +0800 Subject: [PATCH 001/260] Enhance UI test automation by collecting PowerToys logs on failures (#41690) ## Summary of the Pull Request This pull request enhances the test automation infrastructure by improving diagnostics collection when UI tests fail. Specifically, it introduces automatic collection of PowerToys log files, in addition to existing screenshots, to aid in debugging failed tests. **Diagnostics and Logging Improvements:** * Added a new method `AddLogFilesToTestResultsDirectory` to automatically copy PowerToys log files from both `LocalLow` and `LocalAppData` directories to the test results directory when a test fails. The method is robust to errors and will not fail the test if log file copying encounters issues. * Introduced a helper method `CopyLogFilesFromDirectory` that recursively copies `.log` files from the PowerToys directories, renaming them to include their directory structure for easier identification in the test results. * Updated the test failure handling logic to invoke the new log collection method alongside the existing screenshot collection. image ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- src/common/UITestAutomation/UITestBase.cs | 88 +++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/common/UITestAutomation/UITestBase.cs b/src/common/UITestAutomation/UITestBase.cs index f44c62ab62..1c72be05f4 100644 --- a/src/common/UITestAutomation/UITestBase.cs +++ b/src/common/UITestAutomation/UITestBase.cs @@ -4,6 +4,7 @@ using System.Collections.ObjectModel; using System.Diagnostics; +using System.IO; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -94,6 +95,7 @@ namespace Microsoft.PowerToys.UITest { Task.Delay(1000).Wait(); AddScreenShotsToTestResultsDirectory(); + AddLogFilesToTestResultsDirectory(); } } @@ -598,6 +600,92 @@ namespace Microsoft.PowerToys.UITest } } + /// + /// Copies PowerToys log files to test results directory when test fails. + /// Renames files to include the directory structure after \PowerToys. + /// + protected void AddLogFilesToTestResultsDirectory() + { + try + { + var localAppDataLow = Path.Combine( + Environment.GetEnvironmentVariable("USERPROFILE") ?? string.Empty, + "AppData", + "LocalLow", + "Microsoft", + "PowerToys"); + + if (Directory.Exists(localAppDataLow)) + { + CopyLogFilesFromDirectory(localAppDataLow, string.Empty); + } + + var localAppData = Path.Combine( + Environment.GetEnvironmentVariable("LOCALAPPDATA") ?? string.Empty, + "Microsoft", + "PowerToys"); + + if (Directory.Exists(localAppData)) + { + CopyLogFilesFromDirectory(localAppData, string.Empty); + } + } + catch (Exception ex) + { + // Don't fail the test if log file copying fails + Console.WriteLine($"Failed to copy log files: {ex.Message}"); + } + } + + /// + /// Recursively copies log files from a directory and renames them with directory structure. + /// + /// Source directory to copy from + /// Relative path from PowerToys folder + private void CopyLogFilesFromDirectory(string sourceDir, string relativePath) + { + if (!Directory.Exists(sourceDir)) + { + return; + } + + // Process log files in current directory + var logFiles = Directory.GetFiles(sourceDir, "*.log"); + foreach (var logFile in logFiles) + { + try + { + var fileName = Path.GetFileName(logFile); + var fileNameWithoutExt = Path.GetFileNameWithoutExtension(fileName); + var extension = Path.GetExtension(fileName); + + // Create new filename with directory structure + var directoryPart = string.IsNullOrEmpty(relativePath) ? string.Empty : relativePath.Replace("\\", "-") + "-"; + var newFileName = $"{directoryPart}{fileNameWithoutExt}{extension}"; + + // Copy file to test results directory with new name + var testResultsDir = TestContext.TestResultsDirectory ?? Path.GetTempPath(); + var destinationPath = Path.Combine(testResultsDir, newFileName); + + File.Copy(logFile, destinationPath, true); + TestContext.AddResultFile(destinationPath); + } + catch (Exception ex) + { + Console.WriteLine($"Failed to copy log file {logFile}: {ex.Message}"); + } + } + + // Recursively process subdirectories + var subdirectories = Directory.GetDirectories(sourceDir); + foreach (var subdir in subdirectories) + { + var dirName = Path.GetFileName(subdir); + var newRelativePath = string.IsNullOrEmpty(relativePath) ? dirName : Path.Combine(relativePath, dirName); + CopyLogFilesFromDirectory(subdir, newRelativePath); + } + } + /// /// Restart scope exe. /// From a0b49ff6477a87354b9c7f0aa3ce92aa388582f6 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Tue, 9 Sep 2025 10:48:02 +0200 Subject: [PATCH 002/260] [Settings] Add GPO control (#40256) ## Summary of the Pull Request Quality of (dev)life improvement: a dedicated control for showing the GPO-warning InfoBar. As a result, we no longer need to copy-and-paste the same InfoBar XAML all over the place, ensuring that things are consistent and easier to maintain. ## PR Checklist - [x] **Closes:** #40252 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --------- Co-authored-by: Gordon Lam (SH) Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com> --- ...rToys.Settings.DSC.Schema.Generator.csproj | 4 +- .../Settings.UI/PowerToys.Settings.csproj | 3 + .../SettingsXAML/Controls/GPOInfoControl.xaml | 28 ++ .../Controls/GPOInfoControl.xaml.cs | 49 ++++ .../SettingsXAML/Panels/MouseJumpPanel.xaml | 27 +- .../SettingsXAML/Themes/Generic.xaml | 3 +- .../SettingsXAML/Views/AdvancedPastePage.xaml | 50 ++-- .../SettingsXAML/Views/AlwaysOnTopPage.xaml | 26 +- .../SettingsXAML/Views/AwakePage.xaml | 27 +- .../SettingsXAML/Views/CmdPalPage.xaml | 22 +- .../SettingsXAML/Views/ColorPickerPage.xaml | 22 +- .../SettingsXAML/Views/CropAndLockPage.xaml | 26 +- .../Views/EnvironmentVariablesPage.xaml | 25 +- .../SettingsXAML/Views/FancyZonesPage.xaml | 30 +- .../SettingsXAML/Views/FileLocksmithPage.xaml | 26 +- .../SettingsXAML/Views/GeneralPage.xaml | 95 +++---- .../SettingsXAML/Views/HostsPage.xaml | 25 +- .../SettingsXAML/Views/ImageResizerPage.xaml | 27 +- .../Views/KeyboardManagerPage.xaml | 35 +-- .../SettingsXAML/Views/MeasureToolPage.xaml | 32 +-- .../SettingsXAML/Views/MouseUtilsPage.xaml | 76 ++---- .../Views/MouseWithoutBordersPage.xaml | 111 +++----- .../SettingsXAML/Views/NewPlusPage.xaml | 257 ++++++++---------- .../SettingsXAML/Views/PeekPage.xaml | 26 +- .../SettingsXAML/Views/PowerAccentPage.xaml | 27 +- .../SettingsXAML/Views/PowerLauncherPage.xaml | 28 +- .../SettingsXAML/Views/PowerOcrPage.xaml | 25 +- .../SettingsXAML/Views/PowerRenamePage.xaml | 25 +- .../Views/RegistryPreviewPage.xaml | 29 +- .../SettingsXAML/Views/ShortcutGuidePage.xaml | 25 +- .../SettingsXAML/Views/WorkspacesPage.xaml | 27 +- .../SettingsXAML/Views/ZoomItPage.xaml | 26 +- 32 files changed, 499 insertions(+), 765 deletions(-) create mode 100644 src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml create mode 100644 src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml.cs diff --git a/src/dsc/PowerToys.Settings.DSC.Schema.Generator/PowerToys.Settings.DSC.Schema.Generator.csproj b/src/dsc/PowerToys.Settings.DSC.Schema.Generator/PowerToys.Settings.DSC.Schema.Generator.csproj index 83ef8f96b4..3186a01d43 100644 --- a/src/dsc/PowerToys.Settings.DSC.Schema.Generator/PowerToys.Settings.DSC.Schema.Generator.csproj +++ b/src/dsc/PowerToys.Settings.DSC.Schema.Generator/PowerToys.Settings.DSC.Schema.Generator.csproj @@ -31,11 +31,11 @@ - + - + diff --git a/src/settings-ui/Settings.UI/PowerToys.Settings.csproj b/src/settings-ui/Settings.UI/PowerToys.Settings.csproj index 18ee80a5bf..68d0348c7d 100644 --- a/src/settings-ui/Settings.UI/PowerToys.Settings.csproj +++ b/src/settings-ui/Settings.UI/PowerToys.Settings.csproj @@ -161,6 +161,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml new file mode 100644 index 0000000000..73a862f00a --- /dev/null +++ b/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml @@ -0,0 +1,28 @@ + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml.cs new file mode 100644 index 0000000000..8942d5c4db --- /dev/null +++ b/src/settings-ui/Settings.UI/SettingsXAML/Controls/GPOInfoControl.xaml.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices.WindowsRuntime; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Documents; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; + +namespace Microsoft.PowerToys.Settings.UI.Controls; + +public sealed partial class GPOInfoControl : ContentControl +{ + public static readonly DependencyProperty ShowWarningProperty = + DependencyProperty.Register( + nameof(ShowWarning), + typeof(bool), + typeof(GPOInfoControl), + new PropertyMetadata(false, OnShowWarningPropertyChanged)); + + public bool ShowWarning + { + get => (bool)GetValue(ShowWarningProperty); + set => SetValue(ShowWarningProperty, value); + } + + private static void OnShowWarningPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is GPOInfoControl gpoInfoControl) + { + if (gpoInfoControl.ShowWarning) + { + gpoInfoControl.IsEnabled = false; + } + } + } + + public GPOInfoControl() + { + DefaultStyleKey = typeof(GPOInfoControl); + } +} diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml index 478cd994cc..79fd53978c 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml @@ -22,25 +22,14 @@ - - - - - - - - - - + + + + + + - + \ No newline at end of file diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml index 28a28bf0b5..628df84c01 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml @@ -46,23 +46,14 @@ ChildrenTransitions="{StaticResource SettingsCardsAnimations}" Orientation="Vertical" Spacing="2"> - - - - - - - - + + + + + - - - - - - - - + + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml index a5fec151fb..d6194dc5b2 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml @@ -17,25 +17,15 @@ ModuleImageSource="ms-appx:///Assets/Settings/Modules/AlwaysOnTop.png"> - - - - - - - - + + + + + - - - - - - - - - + + + + + - - - - - - + + + + + - - - - - - - - + + + + + - - - - - - - - + + + + + - - - - - - - - - + + + + + - - - - - - - - - + + + + + - - - - - - - - - + + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml index e06d367941..fcdcc0f60d 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml @@ -48,7 +48,6 @@ FontWeight="SemiBold" Foreground="{ThemeResource TextFillColorSecondaryBrush}" /> - - - - - + + + + + + - - - + + + + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml index f988f8917d..5ad3a998ad 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml @@ -14,24 +14,14 @@ - - - - - - - - - + + + + + - - - - - - - - - - + + + + + - - - - - - - - - - + + + + + - ## Summary of the Pull Request The Mouse Utils UI tests were failing because the Name values changed. This PR updates the tests to use AccessibilityId instead, which provides more stable element identification. try to replace all findbyname ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- .../MouseUtils.UITests/FindMyMouseTests.cs | 95 +++++++++---------- .../MouseHighlighterTests.cs | 46 ++++----- .../MouseUtils.UITests/MouseJumpTests.cs | 42 ++++---- .../MousePointerCrosshairsTests.cs | 30 +++--- .../util/MouseUtilsSettings.cs | 42 ++++++++ .../SettingsXAML/Panels/MouseJumpPanel.xaml | 7 +- .../SettingsXAML/Views/FancyZonesPage.xaml | 5 +- .../SettingsXAML/Views/MouseUtilsPage.xaml | 35 +++++-- 8 files changed, 188 insertions(+), 114 deletions(-) diff --git a/src/modules/MouseUtils/MouseUtils.UITests/FindMyMouseTests.cs b/src/modules/MouseUtils/MouseUtils.UITests/FindMyMouseTests.cs index 0877101d60..7cad62decb 100644 --- a/src/modules/MouseUtils/MouseUtils.UITests/FindMyMouseTests.cs +++ b/src/modules/MouseUtils/MouseUtils.UITests/FindMyMouseTests.cs @@ -49,23 +49,23 @@ namespace MouseUtils.UITests settings.BackgroundColor = "000000"; settings.SpotlightColor = "FFFFFF"; - var foundCustom = this.Find("Find My Mouse"); + var foundCustom = this.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouse)); Assert.IsNotNull(foundCustom); if (CheckAnimationEnable(ref foundCustom)) { - foundCustom = this.Find("Find My Mouse"); + foundCustom = this.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouse)); } if (foundCustom != null) { - foundCustom.Find("Enable Find My Mouse").Toggle(true); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(true); SetFindMyMouseActivationMethod(ref foundCustom, "Press Left Control twice"); Assert.IsNotNull(foundCustom, "Find My Mouse group not found."); SetFindMyMouseAppearanceBehavior(ref foundCustom, ref settings); - var excludedApps = foundCustom.Find("Excluded apps"); + var excludedApps = foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseExcludedApps)); if (excludedApps != null) { excludedApps.Click(); @@ -115,23 +115,23 @@ namespace MouseUtils.UITests settings.BackgroundColor = "FF0000"; settings.SpotlightColor = "0000FF"; - var foundCustom = this.Find("Find My Mouse"); + var foundCustom = this.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouse)); Assert.IsNotNull(foundCustom); if (CheckAnimationEnable(ref foundCustom)) { - foundCustom = this.Find("Find My Mouse"); + foundCustom = this.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouse)); } if (foundCustom != null) { - foundCustom.Find("Enable Find My Mouse").Toggle(true); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(true); SetFindMyMouseActivationMethod(ref foundCustom, "Press Left Control twice"); Assert.IsNotNull(foundCustom, "Find My Mouse group not found."); SetFindMyMouseAppearanceBehavior(ref foundCustom, ref settings); - var excludedApps = foundCustom.Find("Excluded apps"); + var excludedApps = foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseExcludedApps)); if (excludedApps != null) { excludedApps.Click(); @@ -170,27 +170,27 @@ namespace MouseUtils.UITests settings.AnimationDuration = "0"; settings.BackgroundColor = "000000"; settings.SpotlightColor = "FFFFFF"; - var foundCustom = this.Find("Find My Mouse"); + var foundCustom = this.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouse)); Assert.IsNotNull(foundCustom); if (CheckAnimationEnable(ref foundCustom)) { - foundCustom = this.Find("Find My Mouse"); + foundCustom = this.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouse)); } if (foundCustom != null) { - foundCustom.Find("Enable Find My Mouse").Toggle(true); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(true); - foundCustom.Find("Enable Find My Mouse").Toggle(false); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(false); - foundCustom.Find("Enable Find My Mouse").Toggle(true); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(true); SetFindMyMouseActivationMethod(ref foundCustom, "Press Left Control twice"); Assert.IsNotNull(foundCustom); SetFindMyMouseAppearanceBehavior(ref foundCustom, ref settings); - var excludedApps = foundCustom.Find("Excluded apps"); + var excludedApps = foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseExcludedApps)); if (excludedApps != null) { excludedApps.Click(); @@ -212,14 +212,14 @@ namespace MouseUtils.UITests VerifySpotlightAppears(ref settings); // [Test Case] Disable FindMyMouse. Verify the overlay no longer appears when you press Left Ctrl twice - foundCustom.Find("Enable Find My Mouse").Toggle(false); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(false); Task.Delay(1000).Wait(); ActivateSpotlight(ref settings); VerifySpotlightDisappears(ref settings); // [Test Case] Press Left Ctrl twice and verify the overlay appears - foundCustom.Find("Enable Find My Mouse").Toggle(true); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(true); Task.Delay(2000).Wait(); ActivateSpotlight(ref settings); VerifySpotlightAppears(ref settings); @@ -240,27 +240,27 @@ namespace MouseUtils.UITests settings.AnimationDuration = "0"; settings.BackgroundColor = "000000"; settings.SpotlightColor = "FFFFFF"; - var foundCustom = this.Find("Find My Mouse"); + var foundCustom = this.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouse)); Assert.IsNotNull(foundCustom); if (CheckAnimationEnable(ref foundCustom)) { - foundCustom = this.Find("Find My Mouse"); + foundCustom = this.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouse)); } if (foundCustom != null) { - foundCustom.Find("Enable Find My Mouse").Toggle(true); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(true); - foundCustom.Find("Enable Find My Mouse").Toggle(false); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(false); - foundCustom.Find("Enable Find My Mouse").Toggle(true); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(true); SetFindMyMouseActivationMethod(ref foundCustom, "Press Left Control twice"); Assert.IsNotNull(foundCustom); SetFindMyMouseAppearanceBehavior(ref foundCustom, ref settings); - var excludedApps = foundCustom.Find("Excluded apps"); + var excludedApps = foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseExcludedApps)); if (excludedApps != null) { excludedApps.Click(); @@ -282,14 +282,14 @@ namespace MouseUtils.UITests VerifySpotlightAppears(ref settings); // [Test Case] Disable FindMyMouse. Verify the overlay no longer appears when you press Left Ctrl twice - foundCustom.Find("Enable Find My Mouse").Toggle(false); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(false); Task.Delay(1000).Wait(); ActivateSpotlight(ref settings); VerifySpotlightDisappears(ref settings); // [Test Case] Press Left Ctrl twice and verify the overlay appears - foundCustom.Find("Enable Find My Mouse").Toggle(true); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(true); Task.Delay(2000).Wait(); ActivateSpotlight(ref settings); VerifySpotlightAppears(ref settings); @@ -310,17 +310,17 @@ namespace MouseUtils.UITests settings.AnimationDuration = "0"; settings.BackgroundColor = "000000"; settings.SpotlightColor = "FFFFFF"; - var foundCustom = this.Find("Find My Mouse"); + var foundCustom = this.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouse)); if (foundCustom != null) { - foundCustom.Find("Enable Find My Mouse").Toggle(true); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(true); - // foundCustom.Find("Enable Find My Mouse").Toggle(false); + // foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(false); SetFindMyMouseActivationMethod(ref foundCustom, "Press Left Control twice"); Assert.IsNotNull(foundCustom, "Find My Mouse group not found."); // SetFindMyMouseAppearanceBehavior(ref foundCustom, ref settings); - var excludedApps = foundCustom.Find("Excluded apps"); + var excludedApps = foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseExcludedApps)); if (excludedApps != null) { excludedApps.Click(); @@ -340,7 +340,7 @@ namespace MouseUtils.UITests // VerifySpotlightSettings(ref settings); // [Test Case] Disable FindMyMouse. Verify the overlay no longer appears when you press Left Ctrl twice - foundCustom.Find("Enable Find My Mouse").Toggle(false); + foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseToggle)).Toggle(false); Task.Delay(2000).Wait(); Session.SendKey(Key.LCtrl, 0, 0); Task.Delay(100).Wait(); @@ -382,9 +382,6 @@ namespace MouseUtils.UITests var colorBackground = this.GetPixelColorString(location.Item1 + radius + 50, location.Item2 + radius + 50); Assert.AreEqual("#" + settings.BackgroundColor, colorBackground); - - var colorBackground2 = this.GetPixelColorString(location.Item1 + radius + 100, location.Item2 + radius + 100); - Assert.AreEqual("#" + settings.BackgroundColor, colorBackground2); } private void ActivateSpotlight(ref FindMyMouseSettings settings) @@ -427,7 +424,7 @@ namespace MouseUtils.UITests private void SetFindMyMouseActivationMethod(ref Custom? foundCustom, string method) { Assert.IsNotNull(foundCustom); - var groupActivation = foundCustom.Find("Activation method"); + var groupActivation = foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseActivationMethod)); if (groupActivation != null) { groupActivation.Click(); @@ -456,17 +453,17 @@ namespace MouseUtils.UITests private void SetFindMyMouseAppearanceBehavior(ref Custom foundCustom, ref FindMyMouseSettings settings) { Assert.IsNotNull(foundCustom); - var groupAppearanceBehavior = foundCustom.Find("Appearance & behavior"); + var groupAppearanceBehavior = foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseAppearanceBehavior)); if (groupAppearanceBehavior != null) { // groupAppearanceBehavior.Click(); - if (foundCustom.FindAll("Overlay opacity (%)").Count == 0) + if (foundCustom.FindAll(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseOverlayOpacity)).Count == 0) { groupAppearanceBehavior.Click(); } // Set the BackGround color - var backgroundColor = foundCustom.Find("Background color"); + var backgroundColor = foundCustom.Find(By.AccessibilityId(MouseUtilsSettings.AccessibilityIds.FindMyMouseBackgroundColor)); Assert.IsNotNull(backgroundColor); var button = backgroundColor.Find