UWP UI自動化測試(一)------WinAppDriver/Inspect.exe環境準備

安裝的軟件:git

一、WinAppDrivergithub

   WinAppDriver官網:https://github.com/Microsoft/WinAppDriver上面有些 demo。json

      Application Driver直接安裝地址:https://github.com/Microsoft/WinAppDriver/releases windows

      或者 https://www.microsoft.com/en-us/download/details.aspx?id=51663api

環境準備

  安裝完成後,默認在系統的:C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exeapp

  這個工具的做用是你寫的測試工程,經過本地 localhost(127.0.0.1)以 json 方式與 WinAppDriver 進行通訊,使 WinAppDriver調用 win32 api來模擬屏幕操做,若是鼠標點擊、拖拽、觸屏手勢等,後續聽說會支持 xbox 手柄、hololens 等操做。工具

惟有啓用Developer Mode,纔可以使咱們的程序可以檢查界面元素及操縱界面。
進入設置,查找Developer Mode便可:測試

 啓用開發者模式:
 

若是遇到錯誤 Developer Mode package failed to install. Error code: 0x80004005,須要按照如下步驟解決:ui

  1. Win + R ,輸入regedit 打開註冊表
  2. 找到如下鍵值:HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU
  3. 在右側面板找到一個叫作UseWUServer的DWORD值,它的值多是1. 雙擊修改該值爲0
  4. 重啓機器
  5. 再次進入「設置」嘗試一次

二、 inspect.exespa

 這個工具是用來查看運行軟件(uwp、win3二、win form、wpf)的 UI 元素的 Name、ID、Text 等等。包含在 Windows SDK 中。

 安裝完 Visual Studio2015後,能夠在 C盤下找到:C:\Program Files (x86)\Windows Kits\10\bin\x64\inspect.exe

 元素對照表:

Client API Locator Strategy Matched Attribute Example
FindElementByAccessibilityId accessibility id AutomationId AppNameTitle
FindElementByClassName class name ClassName TextBlock
FindElementById id RuntimeId (decimal) 42.333896.3.1
FindElementByName name Name Calculator
FindElementByTagName tag name LocalizedControlType (upper camel case) Text

 

 

 

 

 

 

 

相關參考:

UI Testing: What's new with WinAppDriver:https://channel9.msdn.com/Events/Build/2017/P4084

Improving App Quality with UI Automation:https://channel9.msdn.com/Events/Connect/2016/202?ocid=player

Automate Windows And Mac Apps With The WebDriver Protocol - Dan Cuellar, FOODIt:https://www.youtube.com/watch?v=MgBRvQOZhec

StarDriver Enterprise Appium to the Future | Jonathan Lipps:https://www.youtube.com/watch?v=e61OhZzbsEI

github WinAppDriver: https://github.com/microsoft/winappdriver

Modern Dev Practices: Unit Testing:https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Modern-Dev-Practices-Unit-Testing

Inspect.exe: https://msdn.microsoft.com/en-us/library/windows/desktop/dd318521(v=vs.85).aspx

Windows SDK and emulator archive : https://developer.microsoft.com/en-us/windows/downloads/sdk-archive

Windows Automation API: UI Automation:https://msdn.microsoft.com/zh-cn/library/ms726294(vs.85).aspx

AutomationID :https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/use-the-automationid-property

UI Automation Overview: https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-overviewhttps://msdn.microsoft.com/zh-cn/library/ms728097(v=vs.85).aspx

相關文章
相關標籤/搜索