-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Xiaofeng Wang (from Dev Box)
committed
Feb 14, 2025
1 parent
89d5ffb
commit 4f15b63
Showing
3 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# UI tests framework | ||
|
||
A specialized UI test framework for PowerToys that makes it easy to write UI tests for PowerToys modules or settings. Let's start writing UI tests! | ||
|
||
## Before running tests | ||
|
||
- Install Windows Application Driver v1.2.1 from https://github.com/microsoft/WinAppDriver/releases/tag/v1.2.1 to the default directory (`C:\Program Files (x86)\Windows Application Driver`) | ||
|
||
- Enable Developer Mode in Windows settings | ||
|
||
## Running tests | ||
|
||
- Exit PowerToys if it's running. | ||
|
||
- Open `PowerToys.sln` in Visual Studio and build the solution. | ||
|
||
- Run tests in the Test Explorer (`Test > Test Explorer` or `Ctrl+E, T`). | ||
|
||
|
||
## How to add the first UI tests for your modules | ||
|
||
- Create a new project and add the following references to the project file. Change the OutputPath to your own module's path. | ||
``` | ||
<PropertyGroup> | ||
<OutputType>Library</OutputType> | ||
<!-- This is a UI test, so don't run as part of MSBuild --> | ||
<RunVSTest>false</RunVSTest> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\tests\KeyboardManagerUITests\</OutputPath> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="MSTest" /> | ||
<ProjectReference Include="..\..\..\common\UITestAutomation\UITestAutomation.csproj" /> | ||
<Folder Include="Properties\" /> | ||
</ItemGroup> | ||
``` | ||
- Inherit your test class from UITestBase. | ||
>Set Scope: The default scope starts from the PowerToys settings UI. If you want to start from your own module, set the constructor as shown below: | ||
>Default Scope: | ||
``` | ||
[TestClass] | ||
public class RunFancyZonesTest : UITestBase | ||
{ | ||
public RunFancyZonesTest() | ||
: base() | ||
{ | ||
} | ||
} | ||
``` | ||
>Specify Score: | ||
``` | ||
[TestClass] | ||
public class RunFancyZonesTest : UITestBase | ||
{ | ||
public RunFancyZonesTest() | ||
: base(PowerToysModule.FancyZone) | ||
{ | ||
} | ||
} | ||
``` | ||
|
||
- Then you can start using session to perform the UI operations. | ||
|
||
**Example** | ||
See the file: | ||
```PowerToys\src\modules\keyboardmanager\KeyboardManagerUITests\RunKeyboardManagerUITests.cs``` | ||
|
||
|
||
## Extra tools and information | ||
|
||
|
||
**Accessibility Tools**: | ||
While working on tests, you may need a tool that helps you to view the element's accessibility data, e.g. for finding the button to click. For this purpose, you could use [AccessibilityInsights](https://accessibilityinsights.io/docs/windows/overview) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4f15b63
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@check-spelling-bot Report
🔴 Please review
See the 📜action log or 📝 job summary for details.
Unrecognized words (3)
Fancyzone
interited
MInstance
These words are not needed and should be removed
ahk AMPROPERTY AMPROPSETID Breadcrumb CDEF comdef ddf devenum DEVMON DEVSOURCE DGR DIIRFLAG dshow DVH DVHD DVSD DVSL EData ERole fdw FILEINFOSIG Filtergraph Filterx HCERTSTORE IKs iljxck IYUV KSPROPERTY lcb ldx lld LONGLONG LTRB majortype makecab MEDIASUBTYPE mediatype mfplat mic mjpg Msimg msiquery ORAW outpin overlaywindow PAUDIO PINDIR Pnp ppmt previouscamera PROPBAG propvarutil reencode reencoded REFGUID REGFILTER REGFILTERPINS REGPINTYPES regsvr shmem sizeread stl strsafe strutil subquery SYNCMFT TMPVAR vcdl vdi vid VIDCAP VIDEOINFOHEADER vih webcam wistd WVCTo accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the [email protected]:microsoft/PowerToys.git repository
on the
zhaopengwang/UITestAutomation
branch (ℹ️ how do I use this?):If the flagged items are 🤯 false positives
If items relate to a ...
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txt
file matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^
refers to the file's path from the root of the repository, so^README\.md$
would exclude README.md (on whichever branch you're using).well-formed pattern.
If you can write a pattern that would match it,
try adding it to the
patterns.txt
file.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.