Home

Awesome

wdio-winappdriver-example

An example to demostrate WinAppDriver and WebDriverIO integration without appium. An example to demostrate wdio service: wdio-winappdriver-service and wdio-ywinappdriver-service which are used to start/stop WinAppDriver automatically during the testing.

There are two popular JavaScript WebDrivers which could be used for WinAppDriver testing: selenium-webdriver and WebDriverIO.

This is used to demo UI automation testing with WebDriverIO.

WinAppDriver is recommended to do E2E test for Windows apps. Here I validate the calculator using WebDriverIO + WinAppDriver.

Run the test

I assume you have npm and nodejs enviroment ready.

  1. npm install to install the node_modules
  2. run the testing

There are two Windows Application Drivers you can choose: WinAppDriver and YWinAppDriver. WinAppDriver is an official AppDriver supported by Microsoft, and YWinAppDriver is a open-source WinAppDriver implementation developed by Canhua Li

Please download and install WinAppDriver 1.2 and above from https://github.com/microsoft/WinAppDriver/releases

npm run test
npm run ytest

YWinAppDriver itself is packaged to wdio-ywinappdriver-service, so you doesn't need to install ywinappdriver manually. But it depends on .net core 3.1. If you see launch errors, you may need to install .net core runtime 3.1 or above manually.

Things I want to highlights

  1. appium is removed from the dependency. wdio-winappdriver-service and wdio-ywinappdriver-service is used to start & stop the WinAppDriver automatically
  2. GetPageSource and Screenshot on failure
  3. set implicit timeout makes you application have less logs. WinAppDriver and YWinAppDriver use this timer to search the UI element
browser.setTimeout({ implicit: 5000 });
  1. "ms:experimental-webdriver": true is mandatory capability for WinAppDriver

  2. PageObject

  3. Typescript

  4. There is not need to compile .ts to .js before test run because of

require('ts-node').register({ transpileOnly: true });

Note

To know more about how to integrate JavaScript test runner and WinAppDriver for UI automation, please refer to:

  1. Jest + selenium-webdriver + WinAppDriver
  2. Jasmine + WebDriverIO + WinAppDriver. This part is obselete, please refer to WinAppDriver + WebDriverIO example for newer change.