%3CLINGO-SUB%20id%3D%22lingo-sub-1124543%22%20slang%3D%22en-US%22%3EWinAppDriver%20and%20Desktop%20UI%20Test%20Automation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1124543%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EAuthor%20%3A%26nbsp%3B%3CFONT%3EEdwin%20Hernandez%20Maynez%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20article%20is%20a%20follow%20up%20on%20a%20previous%20post%20titled%20%22%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Ftestingspot-blog%2Fui-automation-page-object-model-and-other-design-patterns%2Fba-p%2F992242%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EUI%20Automation%20-%20Page%20Object%20Model%20and%20other%20Design%20Patterns%3C%2FA%3E%22%20and%20is%20part%20of%20a%20series%20of%20posts%20related%20to%20UI%20Test%20automation%2C%20if%20you%20are%20interested%20in%20UI%20automation%20tools%20in%20general%2C%20we%20definitely%20recommend%20checking%20out%20our%20earlier%20post%3A%26nbsp%3B%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Ftestingspot-blog%2Fwhat-are-the-best-ui-test-automation-tools%2Fba-p%2F367781%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%22What%20are%20the%20best%20UI%20Test%20Automation%20Tools%3F%22%3C%2FA%3E%20which%20was%20published%20on%20this%20same%20blog%20not%20so%20long%20ago.%20You%20may%20want%20to%20have%20a%20look%20at%20those%20two%20articles%20since%20it%20provides%20a%20high%20level%20view%20of%20what%20tools%20are%20available%20in%20the%20market%20for%20Functional%20UI%20Test%20automation%2C%20either%20for%20Web%2C%20Mobile%20or%20Desktop%20and%20then%20a%20deeper%20analysis%20of%20code%20design%20approaches.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20article%20I%20will%20describe%20broadly%20the%20technical%20highlights%20of%20how%20Desktop%20UI%20automation%20is%20done%20and%20I%20will%20describe%20the%20main%20features%20of%20a%20relatively%20new%20test%20framework%20that%20is%20becoming%20a%20must-use%20for%20UI%20automation%20for%20Windows-based%20applications.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1414495181%22%20id%3D%22toc-hId--1414495181%22%3EAbout%20CodedUI%3C%2FH2%3E%0A%3CP%3ECodedUI%20is%20a%20Microsoft%20technology%20created%20to%20provide%20support%20of%20Desktop%20and%20Web%20UI%20automation%2C%20this%20technology%20is%20now%20deprecated%20and%20Visual%20Studio%202019%20is%20the%20last%20version%20of%20VS%20that%20will%20include%20it.%20Microsoft%20has%20announced%20that%20it%20recommends%20the%20following%20technologies%20as%20replacements%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWe%20recommend%20using%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.seleniumhq.org%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESelenium%3C%2FA%3E%26nbsp%3Bfor%20testing%20web%20apps%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FMicrosoft%2FWinAppDriver%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAppium%20with%20WinAppDriver%3C%2FA%3E%26nbsp%3Bfor%20testing%20desktop%20and%20UWP%20apps%3C%2FLI%3E%0A%3CLI%3EConsider%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fappcenter%2Ftest-cloud%2Fuitest%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EXamarin.UITest%3C%2FA%3E%26nbsp%3Bfor%20testing%20iOS%20and%20Android%20apps%20using%20the%20NUnit%20test%20framework.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EFrom%20%26lt%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fvisualstudio%2Ftest%2Fuse-ui-automation-to-test-your-code%3Fview%3Dvs-2019%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fvisualstudio%2Ftest%2Fuse-ui-automation-to-test-your-code%3Fview%3Dvs-2019%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGiven%20that%20announcement%2C%20if%20you%20have%20an%20interest%20or%20a%20need%20to%20be%20able%20to%20provide%20Desktop%20UI%20automation%20support%20for%20one%20of%20your%20projects%2C%20please%20read%20forward%20as%20I%20list%20the%20main%20features%20of%20WinAppDriver.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1073017652%22%20id%3D%22toc-hId-1073017652%22%3EWindows%20Application%20Driver%3C%2FH2%3E%0A%3CP%3EWinAppDriver%20is%20a%20test%20framework%20developed%20by%20Microsoft%20as%20an%20open%20source%20project%2C%20it's%20an%20implementation%20of%20Appium%20which%20is%20primarily%20a%20Mobile%20App%20framework%2C%20itself%20based%20on%20Selenium.%20Therefore%20WinAppDriver%20is%20a%20Selenium-like%20automation%20framework.%20This%20project%20is%20combining%20the%20best%20of%20two%20worlds%2C%20on%20one%20hand%20it%20encapsulates%20most%20of%20the%20technology%20of%20the%20now%20deprecated%20CodedUI%20and%20it%20fuses%20it%20with%20the%20flexibility%2C%20easiness%20of%20use%20and%20adoption%20of%20Selenium.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EJust%20like%20Selenium%2C%20WinAppDriver%20is%20a%20set%20of%20libraries%20that%20can%20be%20integrated%20into%20any%20Test%20Runner%20that%20supports%20Appium.%20E.g.%20WinAppDriver%20scripts%20can%20be%20developed%20and%20executed%20with%20MSTest%20from%20Visual%20Studio.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1763579126%22%20id%3D%22toc-hId-1763579126%22%3ERequirements%3C%2FH3%3E%0A%3CUL%3E%0A%3CLI%3EWinAppDriver%20only%20runs%20on%20Windows%2010%3C%2FLI%3E%0A%3CLI%3EYou%20will%20need%20a%20test%20runner%2C%20such%20as%20MSTest%20with%20Visual%20Studio%2C%20but%20any%20other%20Appium%20Test%20Runner%20would%20do%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH3%20id%3D%22toc-hId--43875337%22%20id%3D%22toc-hId--43875337%22%3EWhere%20can%20you%20get%20it%3A%3C%2FH3%3E%0A%3CUL%3E%0A%3CLI%3EDownload%20and%20Install%20the%20latest%20release%20(v1.1%20now)%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2FWinAppDriver%2Freleases%2Ftag%2Fv1.1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoft%2FWinAppDriver%2Freleases%2Ftag%2Fv1.1%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EEnable%20Developer%20Mode%20on%20your%20Windows%2010%20PC%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--54378441%22%20id%3D%22toc-hId--54378441%22%3EDesktop%20UI%20Automation%3C%2FH2%3E%0A%3CP%3EUnlike%20Web%20UI%20automation%2C%20when%20working%20with%20Desktop%20applications%2C%20there%20is%20more%20variance%20on%20the%20technologies%20that%20could%20have%20been%20used%20to%20develop%20the%20application%20you%20are%20testing.%20This%20has%20an%20impact%20in%20the%20toolset's%20ability%20to%20identify%20and%20perform%20actions%20on%20a%20given%20UI%20element%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EUWP%3C%2FSTRONG%3E%20%E2%80%93%20Universal%20Windows%20Platform%2C%20also%20known%20as%20Universal%20Apps%20or%20Modern%20Apps%2C%20It's%20Microsoft%E2%80%99s%20latest%20desktop%20application%20technology.%20It's%20XAML%20based.%20Only%20runs%20on%20Windows%2010%20machines%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EWPF%3C%2FSTRONG%3E%20-%20also%20XAML%20based%2C%20much%20more%20mature%2C%20runs%20on%20any%20Windows%20version%20and%20has%20been%20around%20since%202006.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EWinForms%20-%20%3C%2FSTRONG%3Eone%20of%20the%20older%20technologies%2C%20now%20found%20mostly%20on%20legacy%20applications.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EMFC%2FClassic%20Windows%20-%20%3C%2FSTRONG%3E%26nbsp%3BMFC%20is%20a%20UI%20library%20normally%20paired%20with%20Win32%20applications.%20This%20option%20is%20normally%20chosen%20when%20more%20efficiency%20is%20needed%20with%20low-level%20C%2B%2B%20handling%20or%20when%20supporting%20non-Microsoft%20platforms.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EFrom%20%26lt%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fapps%2Fdesktop%2Fchoose-your-platform%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fapps%2Fdesktop%2Fchoose-your-platform%3C%2FA%3E%26gt%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECodedUI%20is%20an%20umbrella%20framework%20for%20Web%20and%20Desktop%20UI%20technologies%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUI%20Automation%20(UIA)%20and%20Microsoft%20Active%20Accessibility%20(MSAA)%20are%20two%20lower-level%20accessibility%20technologies%20used%20to%20provide%20access%20to%20UI%20elements.%20MSAA%20is%20now%20a%20legacy%20library%20while%20UIA%20is%20newer%20and%20more%20capable.%20UIA%20is%20an%20accessibility%20framework%20not%20a%20test%20framework%20and%20it%20is%20not%20meant%20to%20be%20used%20as%20such.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBoth%20of%20these%20technologies%20are%20now%20under%20the%20hood%20of%20WinAppDriver%2C%20which%20is%20why%20WinAppDriver%20fully%20supports%20the%20desktop%20technologies%20listed%20above%20(UWP%2CWPF%2CWinforms%20%26amp%3B%20MFC).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1861832904%22%20id%3D%22toc-hId--1861832904%22%3EHow%20to%20get%20started%3C%2FH2%3E%0A%3CP%3EI%20will%20provide%20a%20quick%20start%20guide%20and%20simple%20scripts%20on%20Visual%20Studio%202019%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EFirst%20follow%20the%20instructions%20above%20to%20download%20and%20install%20WinAppDriver%2C%20then%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20Unit%20Test%20Project%20in%20Visual%20Studio%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20711px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F166739i23CDE093BBAA6719%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Untitled%20picture1_Jan.png%22%20title%3D%22Untitled%20picture1_Jan.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CUL%3E%0A%3CLI%3EGo%20to%20Manage%20Nuget%20Packages%2C%20then%20Browse%20for%20Appium.WebDriver%3C%2FLI%3E%0A%3CLI%3EInstall%20the%20following%20package%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIt%20should%20automatically%20install%20a%20few%20other%20dependent%20references%20for%20you.%3C%2FLI%3E%0A%3CLI%3ENow%2C%20the%20setup%20for%20a%20non-UWP%20and%20a%20UWP%20app%20changes%20slightly%2C%20please%20find%20below%20two%20examples%20of%20the%20minimal%20code%20needed%20for%20a%20WinAppDriver%20test%20method%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eusing%20System%3B%0Ausing%20System.Diagnostics%3B%0Ausing%20Microsoft.VisualStudio.TestTools.UnitTesting%3B%0Ausing%20OpenQA.Selenium.Appium.Windows%3B%0Ausing%20OpenQA.Selenium.Remote%3B%0A%20%0Anamespace%20Blog%0A%7B%0A%20%5BTestClass%5D%0A%20public%20class%20UITests%0A%20%7B%0A%20%20%0A%20%20%5BTestMethod%5D%0A%20%20public%20void%20SysInfoTest()%0A%20%20%7B%0A%20%20%20Process.Start(%40%22C%3A%5CProgram%20Files%20(x86)%5CWindows%20Application%20Driver%5CWinAppDriver.exe%22)%3B%0A%20%0A%20%20%20WindowsDriver%3CWINDOWSELEMENT%3E%20SysInfoApp%3B%0A%20%20%20DesiredCapabilities%20appCapabilities%20%3D%20new%20DesiredCapabilities()%3B%0A%20%20%20appCapabilities.SetCapability(%22app%22%2C%20%40%22C%3A%5CWindows%5CSystem32%5Cmsinfo32.exe%22)%3B%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20SysInfoApp%20%3D%20new%20WindowsDriver%3CWINDOWSELEMENT%3E(new%20Uri(%22%3CA%20href%3D%22http%3A%2F%2F127.0.0.1%3A4723%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F127.0.0.1%3A4723%3C%2FA%3E%22)%2C%20appCapabilities)%3B%0A%20%0A%20%20%20SysInfoApp.FindElementByName(%22Help%22).Click()%3B%0A%20%20%20SysInfoApp.FindElementByName(%22About%20System%20Info...%22).Click()%3B%0A%20%20%7D%0A%20%20%0A%20%20%5BTestMethod%5D%0A%20%20public%20void%20CalculatorTest()%0A%20%20%7B%0A%20%20%20Process.Start(%40%22C%3A%5CProgram%20Files%20(x86)%5CWindows%20Application%20Driver%5CWinAppDriver.exe%22)%3B%0A%20%0A%20%20%20WindowsDriver%3CWINDOWSELEMENT%3E%20Calculator%3B%0A%20%20%20DesiredCapabilities%20appCapabilities%20%3D%20new%20DesiredCapabilities()%3B%0A%20%20%20appCapabilities.SetCapability(%22app%22%2C%20%22Microsoft.WindowsCalculator_8wekyb3d8bbwe!App%22)%3B%0A%20%20%20Calculator%20%3D%20new%20WindowsDriver%3CWINDOWSELEMENT%3E(new%20Uri(%22%3CA%20href%3D%22http%3A%2F%2F127.0.0.1%3A4723%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F127.0.0.1%3A4723%3C%2FA%3E%22)%2C%20appCapabilities)%3B%0A%20%0A%20%20%20Calculator.FindElementByAccessibilityId(%22num5Button%22).Click()%3B%0A%20%20%20Calculator.FindElementByAccessibilityId(%22plusButton%22).Click()%3B%0A%20%20%20Calculator.FindElementByAccessibilityId(%22num3Button%22).Click()%3B%0A%20%20%20Calculator.FindElementByAccessibilityId(%22equalButton%22).Click()%3B%20%20%20%20%20%0A%20%20%7D%0A%20%7D%0A%7D%3C%2FWINDOWSELEMENT%3E%3C%2FWINDOWSELEMENT%3E%3C%2FWINDOWSELEMENT%3E%3C%2FWINDOWSELEMENT%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eusing%20System%3B%3C%2FP%3E%0A%3CP%3Eusing%20System.Diagnostics%3B%3C%2FP%3E%0A%3CP%3Eusing%20Microsoft.VisualStudio.TestTools.UnitTesting%3B%3C%2FP%3E%0A%3CP%3Eusing%20OpenQA.Selenium.Appium.Windows%3B%3C%2FP%3E%0A%3CP%3Eusing%20OpenQA.Selenium.Remote%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Enamespace%20Blog%3C%2FP%3E%0A%3CP%3E%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5BTestClass%5D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20public%20class%20UITests%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5BTestMethod%5D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20public%20void%20SysInfoTest()%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Process.Start(%40%22C%3A%5CProgram%20Files%20(x86)%5CWindows%20Application%20Driver%5CWinAppDriver.exe%22)%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20WindowsDriver%3CWINDOWSELEMENT%3E%20SysInfoApp%3B%3C%2FWINDOWSELEMENT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20DesiredCapabilities%20appCapabilities%20%3D%20new%20DesiredCapabilities()%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20appCapabilities.SetCapability(%22app%22%2C%20%40%22C%3A%5CWindows%5CSystem32%5Cmsinfo32.exe%22)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SysInfoApp%20%3D%20new%20WindowsDriver%3CWINDOWSELEMENT%3E(new%20Uri(%22%3CA%20href%3D%22http%3A%2F%2F127.0.0.1%3A4723%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F127.0.0.1%3A4723%3C%2FA%3E%22)%2C%20appCapabilities)%3B%3C%2FWINDOWSELEMENT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SysInfoApp.FindElementByName(%22Help%22).Click()%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SysInfoApp.FindElementByName(%22About%20System%20Info...%22).Click()%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5BTestMethod%5D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20public%20void%20CalculatorTest()%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Process.Start(%40%22C%3A%5CProgram%20Files%20(x86)%5CWindows%20Application%20Driver%5CWinAppDriver.exe%22)%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20WindowsDriver%3CWINDOWSELEMENT%3E%20Calculator%3B%3C%2FWINDOWSELEMENT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20DesiredCapabilities%20appCapabilities%20%3D%20new%20DesiredCapabilities()%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20appCapabilities.SetCapability(%22app%22%2C%20%22Microsoft.WindowsCalculator_8wekyb3d8bbwe!App%22)%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Calculator%20%3D%20new%20WindowsDriver%3CWINDOWSELEMENT%3E(new%20Uri(%22%3CA%20href%3D%22http%3A%2F%2F127.0.0.1%3A4723%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F127.0.0.1%3A4723%3C%2FA%3E%22)%2C%20appCapabilities)%3B%3C%2FWINDOWSELEMENT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Calculator.FindElementByAccessibilityId(%22num5Button%22).Click()%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Calculator.FindElementByAccessibilityId(%22plusButton%22).Click()%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Calculator.FindElementByAccessibilityId(%22num3Button%22).Click()%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Calculator.FindElementByAccessibilityId(%22equalButton%22).Click()%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%7D%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESimilarly%20to%20Selenium%2C%20in%20WinAppDriver%2C%20elements%20are%20found%20by%20providing%20identifiable%20properties%20such%20as%20Class%2C%20Id%2C%20Name%2C%20AccessibilityID%2C%20Xpath%2C%20etc.%20You%20can%20spy%20these%20properties%20using%20a%20few%20other%20tools%20such%20as%3A%3C%2FLI%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2FWinAppDriver%2Freleases%2Ftag%2FUIR-v1.1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EWinAppDriver%20Recorder%3C%2FA%3E%2C%20compact%20app%20provided%20by%20the%20same%20team%2C%20gives%20you%20an%20Xpath%20to%20the%20element%20you%20need.%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fwinauto%2Finspect-objects%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EInspect.exe%3C%2FA%3E%2C%20powerful%20tool%20that%20comes%20with%20the%20Microsoft%20SDK%2C%20it%20also%20provides%20pattern%20recognition%20for%20UIA%20accessibility.%20Use%20the%20properties%20listed%20for%20a%20given%20element%20to%20find%20it%20with%20WinAppDriver.%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fvisualstudio%2Fdebugger%2Fhow-to-start-spy-increment%3Fview%3Dvs-2019%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESpy%2B%2B.%3C%2FA%3E%20An%20object%20identification%20tool%20that%20comes%20with%20Visual%20Studio.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CLI%3EThat%20should%20be%20it%2C%20now%20you%20have%20a%20fully-working%20WinAppDriver%20test%20framework.%20It%20may%20sound%20easy%20to%20get%20started%20but%20the%20challenge%20on%20UI%20automation%20is%20not%20on%20the%20initial%20setup%20but%20on%20the%20maintainability%2C%20good%20coding%20practices%20and%20the%20feasibility%20of%20the%20framework%20to%20identify%20all%20the%20UI%20elements%20that%20you%20will%20need.%20Here%20are%20some%20pointers%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-625679929%22%20id%3D%22toc-hId-625679929%22%3ETips%20and%20Tricks%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3EDepending%20on%20the%20Desktop%20development%20technology%20that%20was%20used%20to%20create%20the%20app%20you%20are%20testing%2C%20and%20depending%20on%20whenever%20or%20not%20the%20developers%20chose%20to%20use%20the%20out-of-the%20box%20UI%20elements%20or%20chose%20to%20customize%20them%2C%20finding%20elements%20can%20be%20a%20piece%20of%20cake%20or%20a%20real%20pain.%3C%2FLI%3E%0A%3CLI%3EEven%20if%20the%20developers%20used%20the%20standard%20UI%20elements%2C%20if%20they%20are%20not%20including%20an%20UIAutomation%20property%20or%20if%20they%20are%20leaving%20properties%20like%20name%2Ftext%20blank%20or%20the%20same%20for%20different%20elements%E2%80%A6then%20identifying%20elements%20can%20be%20challenging.%3C%2FLI%3E%0A%3CLI%3EMy%20recommendation%20here%20is%20to%20use%20xpath%20to%20its%20full%20extent%3A%20look%20into%20functions%20such%20as%20contains()%2C%20last()%2C%20first()%2C%20sibling()%2C%20etc.%20%E2%80%A6%20find%20how%20to%20go%20up%20or%20down%20levels%20on%20the%20xpath%20tree%20to%20navigate%20to%20the%20element%20you%20need%20out%20of%20another%20one.%20You%20can%20also%20use%20WinAppDriver%20findElements%20method%20to%20pull%20all%20matching%20elements%20into%20a%20Collection%20and%20just%20iterate%20thru%20it%20until%20you%20find%20the%20one%20you%20need.%3C%2FLI%3E%0A%3CLI%3EYou%20may%20find%20that%20WinAppDriver%20just%20as%20CodedUI%2C%20may%20not%20be%20able%20to%20inspect%20or%20drill%20down%20into%20certain%20elements%2C%20especially%20when%20these%20elements%20are%20customized%20or%20on%20certain%20corner%20cases%20of%20the%20older%20technologies%20(Winforms%20or%20MFC).%20In%20this%20case%20you%20may%20need%20to%20dive%20into%20using%20UIA%20patterns%20to%20find%20and%20perform%20actions%20into%20these%20elements.%3C%2FLI%3E%0A%3CLI%3EMaintainability%20and%20fragility%20of%20UI%20scripts%20to%20changes%20really%20becomes%20an%20issue%20as%20your%20project%20grows.%20Look%20into%20Design%20Patterns%20such%20as%20Page-Object-Model%20(I%20just%20wrote%20an%20article%20about%20this%2C%20you%20can%20find%20a%20link%20to%20it%20at%20the%20top%20of%20this%20page)%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1124543%22%20slang%3D%22en-US%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-us%22%3EIn%20this%20article%20I%20will%20describe%20broadly%20the%20technical%20highlights%20of%20how%20Desktop%20UI%20automation%20is%20done%20and%20I%20will%20describe%20the%20main%20features%20of%20a%20relatively%20new%20test%20framework%20that%20is%20becoming%20a%20must-use%20for%20UI%20automation%20for%20Windows-based%20applications.%3C%2FP%3E%3C%2FLINGO-TEASER%3E

Author : Edwin Hernandez Maynez

 

This article is a follow up on a previous post titled "UI Automation - Page Object Model and other Design Patterns" and is part of a series of posts related to UI Test automation, if you are interested in UI automation tools in general, we definitely recommend checking out our earlier post:  "What are the best UI Test Automation Tools?" which was published on this same blog not so long ago. You may want to have a look at those two articles since it provides a high level view of what tools are available in the market for Functional UI Test automation, either for Web, Mobile or Desktop and then a deeper analysis of code design approaches.

 

In this article I will describe broadly the technical highlights of how Desktop UI automation is done and I will describe the main features of a relatively new test framework that is becoming a must-use for UI automation for Windows-based applications.

 

About CodedUI

CodedUI is a Microsoft technology created to provide support of Desktop and Web UI automation, this technology is now deprecated and Visual Studio 2019 is the last version of VS that will include it. Microsoft has announced that it recommends the following technologies as replacements:

 

From <https://docs.microsoft.com/en-us/visualstudio/test/use-ui-automation-to-test-your-code?view=vs-2019

 

Given that announcement, if you have an interest or a need to be able to provide Desktop UI automation support for one of your projects, please read forward as I list the main features of WinAppDriver.

 

Windows Application Driver

WinAppDriver is a test framework developed by Microsoft as an open source project, it's an implementation of Appium which is primarily a Mobile App framework, itself based on Selenium. Therefore WinAppDriver is a Selenium-like automation framework. This project is combining the best of two worlds, on one hand it encapsulates most of the technology of the now deprecated CodedUI and it fuses it with the flexibility, easiness of use and adoption of Selenium.

 

Just like Selenium, WinAppDriver is a set of libraries that can be integrated into any Test Runner that supports Appium. E.g. WinAppDriver scripts can be developed and executed with MSTest from Visual Studio.

 

Requirements

  • WinAppDriver only runs on Windows 10
  • You will need a test runner, such as MSTest with Visual Studio, but any other Appium Test Runner would do

Where can you get it:

 

Desktop UI Automation

Unlike Web UI automation, when working with Desktop applications, there is more variance on the technologies that could have been used to develop the application you are testing. This has an impact in the toolset's ability to identify and perform actions on a given UI element:

  • UWP – Universal Windows Platform, also known as Universal Apps or Modern Apps, It's Microsoft’s latest desktop application technology. It's XAML based. Only runs on Windows 10 machines
  • WPF - also XAML based, much more mature, runs on any Windows version and has been around since 2006.
  • WinForms - one of the older technologies, now found mostly on legacy applications.
  • MFC/Classic Windows -  MFC is a UI library normally paired with Win32 applications. This option is normally chosen when more efficiency is needed with low-level C++ handling or when supporting non-Microsoft platforms.

From <https://docs.microsoft.com/en-us/windows/apps/desktop/choose-your-platform>

 

CodedUI is an umbrella framework for Web and Desktop UI technologies:

Untitled picture_jan.png

 
 

 

UI Automation (UIA) and Microsoft Active Accessibility (MSAA) are two lower-level accessibility technologies used to provide access to UI elements. MSAA is now a legacy library while UIA is newer and more capable. UIA is an accessibility framework not a test framework and it is not meant to be used as such.

 

Both of these technologies are now under the hood of WinAppDriver, which is why WinAppDriver fully supports the desktop technologies listed above (UWP,WPF,Winforms & MFC).

 

How to get started

I will provide a quick start guide and simple scripts on Visual Studio 2019:

  • First follow the instructions above to download and install WinAppDriver, then
  • Create a Unit Test Project in Visual Studio

Untitled picture1_Jan.png

 
  • Go to Manage Nuget Packages, then Browse for Appium.WebDriver
  • Install the following package:
 

 

  • It should automatically install a few other dependent references for you.
  • Now, the setup for a non-UWP and a UWP app changes slightly, please find below two examples of the minimal code needed for a WinAppDriver test method:

 

 

 

 

 

 

using System;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Remote;
 
namespace Blog
{
	[TestClass]
	public class UITests
	{
		
		[TestMethod]
		public void SysInfoTest()
		{
			Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");
 
			WindowsDriver<WindowsElement> SysInfoApp;
			DesiredCapabilities appCapabilities = new DesiredCapabilities();
			appCapabilities.SetCapability("app", @"C:\Windows\System32\msinfo32.exe");            
			SysInfoApp = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
 
			SysInfoApp.FindElementByName("Help").Click();
			SysInfoApp.FindElementByName("About System Info...").Click();
		}
  
		[TestMethod]
		public void CalculatorTest()
		{
			Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");
 
			WindowsDriver<WindowsElement> Calculator;
			DesiredCapabilities appCapabilities = new DesiredCapabilities();
			appCapabilities.SetCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
			Calculator = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
 
			Calculator.FindElementByAccessibilityId("num5Button").Click();
			Calculator.FindElementByAccessibilityId("plusButton").Click();
			Calculator.FindElementByAccessibilityId("num3Button").Click();
			Calculator.FindElementByAccessibilityId("equalButton").Click();     
		}
	}
}

 

 

 

 

 

 

 

  • Similarly to Selenium, in WinAppDriver, elements are found by providing identifiable properties such as Class, Id, Name, AccessibilityID, Xpath, etc. You can spy these properties using a few other tools such as:
    • WinAppDriver Recorder, compact app provided by the same team, gives you an Xpath to the element you need.
    • Inspect.exe, powerful tool that comes with the Microsoft SDK, it also provides pattern recognition for UIA accessibility. Use the properties listed for a given element to find it with WinAppDriver.
    • Spy++. An object identification tool that comes with Visual Studio.
  • That should be it, now you have a fully-working WinAppDriver test framework. It may sound easy to get started but the challenge on UI automation is not on the initial setup but on the maintainability, good coding practices and the feasibility of the framework to identify all the UI elements that you will need. Here are some pointers:

 

Tips and Tricks

  • Depending on the Desktop development technology that was used to create the app you are testing, and depending on whenever or not the developers chose to use the out-of-the box UI elements or chose to customize them, finding elements can be a piece of cake or a real pain.
  • Even if the developers used the standard UI elements, if they are not including an UIAutomation property or if they are leaving properties like name/text blank or the same for different elements…then identifying elements can be challenging.
  • My recommendation here is to use xpath to its full extent: look into functions such as contains(), last(), first(), sibling(), etc. … find how to go up or down levels on the xpath tree to navigate to the element you need out of another one. You can also use WinAppDriver findElements method to pull all matching elements into a Collection and just iterate thru it until you find the one you need.
  • You may find that WinAppDriver just as CodedUI, may not be able to inspect or drill down into certain elements, especially when these elements are customized or on certain corner cases of the older technologies (Winforms or MFC). In this case you may need to dive into using UIA patterns to find and perform actions into these elements.
  • Maintainability and fragility of UI scripts to changes really becomes an issue as your project grows. Look into Design Patterns such as Page-Object-Model (I just wrote an article about this, you can find a link to it at the top of this page)
10 Comments
Visitor

Hello This is a Awesome Article

Senior Member

@Jivant1620: Glad you liked it, thanks for the feedback!

Occasional Visitor

Thanks for the nice article. What is currently bothering me is the complete lack of activity in the github repo. There's also an issue on this topic, but no feedback from Microsoft. Do you have any corresponding information you can share?

Senior Member

Hi @bmueller, thanks for your comment. I reached out to Hassan and he told me that the WinAppDriver team is ongoing a transition. He will update the other thread with more information in the coming weeks.

 

All I can say is that WinAppDriver is a key part of the toolset that my team (Microsoft Test Team) uses on our Consulting and Premier engagements and we will keep advocating for it internally.

Occasional Visitor

Why does this tool asked for the Developer Mode? 

Senior Member

@tdurovastorz :

I don't know the exact reason why Developer Mode is a requirement, I suspect is has something to do with been able to debug and drive UI actions into a packaged windows 10 app. There is an enhancement proposed to make away with this requirement, in case you want to add your comments there: https://github.com/microsoft/WinAppDriver/issues/975

 

Occasional Visitor

@Edwin Hernandez

 

Thanks for relaying this to Hassan.

 

It is frustrating, however, months later after being promised more information, a roadmap, etc., is it as dead as before.

 

Do you have any timescales of when any activity is likely to happen, if at all still?  There is a growing unquietness on the issues for the project that there is no support for what is essentially a black box product that no longer seems to have official support anymore.  If it were open sourced, the community could be involved in resolving more of these issues.

 

Appreciate the current circumstances may have changed priorities, but after previous communications and the fact the only supported testing tool for this area now supported has received no support for over half a year, it would be good to have something more tangible now than just distant promises.

Occasional Visitor

Desired Capabilities is depreciated so use the below code

 

[TestClass]
public class UnitTest1
{
[TestMethod]
public void CalculatorTest()
{
Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");

WindowsDriver<WindowsElement> Calculator;

AppiumOptions appiumOptions = new AppiumOptions();
appiumOptions.AddAdditionalCapability("deviceName", "WindowsPC");
appiumOptions.AddAdditionalCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
Uri url = new Uri("http://127.0.0.1:4723");

Calculator = new WindowsDriver<WindowsElement>(url, appiumOptions);

Calculator.FindElementByAccessibilityId("num5Button").Click();
Calculator.FindElementByAccessibilityId("plusButton").Click();
Calculator.FindElementByAccessibilityId("num3Button").Click();
Calculator.FindElementByAccessibilityId("equalButton").Click();

}
}

 

Note: Make sure that you change Windows 10 to Developer Mode else you ll get an error like this.

Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:4723

Occasional Visitor

If we have to change it to Developer Mode in Windows 10 then how can we run the automation tests in Azure Devops?

Occasional Visitor

@Edwin Hernandez 

@Microsoft_Testing_Team 

 

Any updates on Winappdriver’s development? I advocated its use for our automation but am wary of my decision due to the lack of development or roadmap.