winappdriver - windows store apps test automation

31
12/11/2014 Windows Store Apps Test Automation Jeremy Kao (about.me/imsardine) @ KKBOX SQA Team GTAC 2014 @ Google Kirkland Seattle , WA

Upload: jeremy-kao

Post on 12-Jul-2015

345 views

Category:

Software


4 download

TRANSCRIPT

Page 1: WinAppDriver - Windows Store Apps Test Automation

12/11/2014

Windows Store Apps Test AutomationJeremy Kao (about.me/imsardine) @ KKBOX SQA Team

GTAC 2014 @ Google KirklandSeattle, WA

Page 2: WinAppDriver - Windows Store Apps Test Automation

01

Agenda

✤ UI Automation (UIA)!

✤ UIA Security Model!

✤ Survey!

✤ WinAppDriver

Page 3: WinAppDriver - Windows Store Apps Test Automation

01

UI Automation(UIA)

Bellevue TC Seattle, WA

Page 4: WinAppDriver - Windows Store Apps Test Automation

UIA Overview

✤ Provider and Clients!

✤ Provider API - to create support for custom controls.!

✤ Client API - to create assistive technologies or implement automated testing.!

✤ Support various UI frameworks, including Win32, WinForms, WPF, HTML, Silverlight.!

✤ Provide a unified object model that masks any differences in the UI frameworks.

Page 5: WinAppDriver - Windows Store Apps Test Automation

Testing Tools in Windows SDK

✤ Inspect (formerly known as UI Spy) - for inspecting element's accessibility data, including UIA properties and MSAA properties.!

✤ AccScope - for evaluating accessibility in the early phase of development, and finding out areas needed to be improved.!

✤ Both are good examples of UIA clients.

Page 6: WinAppDriver - Windows Store Apps Test Automation

Key UIA Properties

✤ Automation ID - not localized, preferred.!

✤ Control Type!

✤ Name - may be localized.!

✤ Set a Unique Automation Property for Windows Store Controls for Testing

Page 7: WinAppDriver - Windows Store Apps Test Automation

01

UIASecurity Model

✤ Be signed and trusted!

✤ uiAccess=“true” (manifest)!

✤ Be installed in a secure location

Pike Market Seattle, WA

Page 8: WinAppDriver - Windows Store Apps Test Automation

Security Considerations

To use UIAccess, an assistive technology application needs to:!

✤ Be signed with a certificate to interact with applications running at a higher privilege level.!

✤ Be trusted by the system and run with administrative privileges. The application must be installed in a secure location that requires a user account control (UAC) prompt to write to (for example, the Program Files folder).!

✤ Be built with a manifest file that includes the UIAccess flag.

Source: Security Considerations for Assistive Technologies (Windows)

Page 9: WinAppDriver - Windows Store Apps Test Automation

Be Signed and Trusted

To interact with applications running at a higher privilege level.

Process Explorer

Page 10: WinAppDriver - Windows Store Apps Test Automation

uiAccess=“true” (manifest)

To gain access to the protected system UI.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <!-- omitted --> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="true"></requestedExecutionLevel> </requestedPrivileges> </security> </trustInfo> </assembly>

The manifest of Inspect.exe:

Page 11: WinAppDriver - Windows Store Apps Test Automation

Test Code in C#

var accField = app.FindFirst(TreeScope.Descendants,

new PropertyCondition(AutomationElement.AutomationIdProperty, "txt_UserId"));

((ValuePattern)accField.GetCurrentPattern(ValuePattern.Pattern)).setValue("account");

! var pwdField = app.FindFirst(TreeScope.Descendants,

new PropertyCondition(AutomationElement.AutomationIdProperty, "txt_UserPwd"));

((ValuePattern)pwdField.GetCurrentPattern(ValuePattern.Pattern)).setValue("secret");

! var loginBtn = app.FindFirst(TreeScope.Descendants,

new PropertyCondition(AutomationElement.AutomationIdProperty, "btn_Login"));

((InvokePattern)loginBtn.GetCurrentPattern(InvokePattern.Pattern)).Invoke();

Test Code in Python

Page 12: WinAppDriver - Windows Store Apps Test Automation

01

Survey✤ Code UI Test (VS Premium/Ultimate)!✤ IronPython!✤ Python for .NET!✤ WinAppDriver

Gum WallPike Market, Seattle, WA

Page 13: WinAppDriver - Windows Store Apps Test Automation

Requirements

✤ Scriptable in Python ➠ Robot Framework and PyUIA integration!

✤ Support Windows Vista (.NET Framework 3.0 included) and above.!

✤ As a testing tool, it is important to have fewer dependencies.!

✤ Remote control (RC)

Page 14: WinAppDriver - Windows Store Apps Test Automation

RF & PyUIA Integration

Page 15: WinAppDriver - Windows Store Apps Test Automation

Python for .NET != IronPython

If you want to mainly base your code on the .NET framework, I'd highly recommend IronPython vs Python.NET. IronPython is pretty much native .NET - so it just works great when integrating with other .NET languages.!

Python.NET is good if you want to just integrate one or two components from .NET into a standard python application.

Source: IronPython vs. Python .NET - Stack Overflow

Page 16: WinAppDriver - Windows Store Apps Test Automation

IronPython

✤ It works, but is slow and buggy?!

✤ Not 100% compatible with CPython, subtle differences may lead to big issues in the future.!

✤ No longer supported by Microsoft.

Page 17: WinAppDriver - Windows Store Apps Test Automation

Python for .NET

✤ It works and performs very well.!

✤ We have to modify Python executable’s manifest and resign it. (tricky)!

✤ BTW, the Python code manipulating UIA API looks weird.

Page 18: WinAppDriver - Windows Store Apps Test Automation

01

WinAppDriver

✤ Incubated by KKBOX SQA team.!

✤ imsardine/winappdriver (GitHub)!

✤ MIT License

First Starbucks Store Pike Market, Seattle, WA

Page 19: WinAppDriver - Windows Store Apps Test Automation

Initial Discussion

URL: http://lnkd.in/eKTVuKk

Page 20: WinAppDriver - Windows Store Apps Test Automation

Selenium for Browsers

Language bindings - Python, Ruby, Node.js, Java, C#, …

Source: http://imsardine.simplbug.com/note/selenium2/selenium2.html

Page 21: WinAppDriver - Windows Store Apps Test Automation

Appium for Mobile Apps

Source: http://imsardine.simplbug.com/note/appium/appium.html

Page 22: WinAppDriver - Windows Store Apps Test Automation

Test

WinAppDriver for Win (Store) Apps

WinAppDriver

UIA Client API

WPFWinFormsWin32

http://*:4444/wd/hub

Test

Windows DevicesWin & Unix-like

JSON/WebDriver!Wire Protocol

Lang. Bindings

Page 23: WinAppDriver - Windows Store Apps Test Automation

JSON/WebDriver Wire Protocol

Source: The WebDriver Wire Protocol

Page 24: WinAppDriver - Windows Store Apps Test Automation

WinAppDriver for Windows XYZ

WinAppDriver

UIA Client API

Win Phone?

Store Apps

Desktop!Apps

✤ Written in C#.!

✤ Implement JSON/WebDriver Wire Protocol.!

✤ Support desktop applications and store apps.!

✤ WP support is planned.

Page 25: WinAppDriver - Windows Store Apps Test Automation

Test Code in Python

from selenium.webdriver import Remote, DesiredCapabilitiesdesired_caps = { 'app': 'http://.../AppPackages_0098.zip', 'appUserModelId': '2DE213C9.KKBOX_wttxem0f9q9s0!App', 'appWindowName': 'KKBOX', 'newCommandTimeout': 10 * 60, } driver = Remote('http://172.16.41.128:4444/wd/hub', desired_caps)

driver.find_element_by_id(‘txt_UserId’).set_value('account') driver.find_element_by_id(‘txt_UserPwd’).set_value('secret') driver.find_element_by_id(‘btn_Login’).click()

Test Code in C#

Page 26: WinAppDriver - Windows Store Apps Test Automation

Benefits

✤ REPL (Read–Eval–Print Loop)!

✤ Freedom of choice!

✤ Programming languages!

✤ Testing frameworks!

✤ Operating systems on which test code will run.!

✤ Support Windows Vista and above.!

✤ Remote control - SUT and test code are not necessary to be run on the same machine. (deployment flexibility)

Page 27: WinAppDriver - Windows Store Apps Test Automation

Similar Projects

✤ jasongdove/win-driver (prototyping? 08/05/2013)!

✤ Based on TestStask.White and ServiceStack (commercial licensing).!

✤ Does’t support store apps and touch gestures yet.!

✤ Twin (eBay, 08/21/2011)!

✤ Use UIA client API immediately.!

✤ Doesn’t support store apps and touch gestures yet.!

✤ Does not follow the standard, that’s why a dedicated Java client library is needed.

Page 28: WinAppDriver - Windows Store Apps Test Automation

TODO

✤ Download, install and uninstall app packages automatically.!

✤ PyUIA Integration!

✤ Implement remaining commands defined in the protocol. (logs, screenshots, …)!

✤ Fast reset - clear data without uninstalling the package!

✤ WP support.!

✤ MacDriver for OS X test automation? (appium/appium-for-mac)

Page 29: WinAppDriver - Windows Store Apps Test Automation

References

✤ UI Automation Overview, Using UI Automation for Automated Testing, Testing Tools - Windows Automation API!

✤ Automating the testing of Windows 8 apps - Windows 8 app developer blog - Site Home - MSDN Blogs (09-05-2012)!

✤ UI Automation Security Overview, Security Considerations for Assistive Technologies (Windows)!

✤ Windows Store Applications and Automated Testing – Part One, Two, Three (06/12/2013)

Page 30: WinAppDriver - Windows Store Apps Test Automation

01

Q&A

Bike Travel Seattle, WA

Page 31: WinAppDriver - Windows Store Apps Test Automation

01

WinAppDriver Dev.✤ Env. - Windows SDK + Notepad!

✤ How To Build!

✤ Web server (HttpListener), request manager, session manager, sessions, endpoints, handlers, JSON (json.NET)

Sound TrainSeattle, WA