Test Windows applications with Appium and JavaScript.

Octocat[1]A sample implementation is available on GitHub.

Appium is an opensource test framework for validating native and web apps. It can drive iOS, Android and Windows applications via the well-known Selenium WebDriver protocol.

Appium can be used from any tool, any language, any test tool and for any platform, if there are is a WebDriver for the platform and language-specific client libraries for the Selenium WebDriver API.

Platform, Windows.

To run validations on the Windows platform Microsoft offers an opensource Windows Driver based on the WebDriver protocol. The Appium test framework works with this WebDriver protocol to control the actions on the application undertest.

This decoupling of the test framework from the platform via drivers makes it easy to use the same test set for different platforms. Ideal for Apps which can be hosted on multiple platforms. Which more and more languages support (JavaScript, Net Core, Java). Not only via the browser but also as an Desktop App.

Installing the Appium Windows Driver.

There are different ways to get the Appium Windows Driver on your Windows platform. Via installer packages delivered on the Microsoft GitHub project.

1

or via a node package https://www.npmjs.com/package/appium-windows-driver

appium windows driver

Installing Appium.

With the driver alone, you’re not done yet. The Appium windows Driver takes care of the Appium actions translation to the Windows environment. A different driver will take the Appium actions on a different platform, happy decoupling.

Installing Appium can also be done on two different ways, via a installer package with the Appium Desktop and via a NPM package.

2

Installing both is an option, or better install the Desktop on the test authoring environment, it has the capability to inspect the application under test, and install the NPM Appium server on the test environment.

After the NPM the appium command will start the Appium server.

3

Inspect.

The Appium Desktop App comes with some additional capabilities next to start the server (which listens for request to execute on the driver). It also makes it possible to inspect your application undertest.


The desired capabilities are used to communicate the proper way with the driver, for Windows this is: Platform “Windows” and devicename “windowsPC” with for Store Apps the full app name and for desktop apps the location of the executable.

4

The xPath paths can come handy when authoring the tests. When the Appium inspector doesn’t bring you what you need you can use other inspectors. The Windows SDK comes with an inspector application which can be found in the programs file directory, Inspect.exe. https://msdn.microsoft.com/en-us/library/windows/desktop/dd318521(v=vs.85).aspx and there are more, see this list: https://github.com/blackrosezy/gui-inspect-tool 

5


Language, JavaScript.

A good practice is to write the UI tests in the same language as the programming language used to write the system under test. I should be obvious to write the test in C#. To write Appium test in C# with you also need some additional Nuget packages from where the Appium Webdriver contains the necessary methods (in Appium.WebDriver.3.0.0.2\lib\net45\appium-dotnet-driver.dll ) for creating sessions to the Appium Server.

6

The same when you want to author your tests in Java, it requires an import from the io.appium.java_client.windows.WindowsDriver package.

7

When you write your desktop app in JavaScript (when writing on top of https://electron.atom.io/) or when the most common used test script language in your organization is JS.

For JavaScript there isn’t a specific WindowsDriver package, you can use WD.js (or http://webdriver.io/), it is a Node.js Webdriver/Selenium 2 client (http://admc.io/wd/ ) together with Node selenium WebDriver (https://www.npmjs.com/package/selenium-webdriver).

Next to the libraries which help with the communication with the Appium Server you also need a testing framework. Mocha and Jasmine are the two most popular ones. (see: https://stateofjs.com/2016/testing/ and https://www.codementor.io/codementorteam/javascript-testing-framework-comparison-jasmine-vs-mocha-8s9k27za3 ) feel free to use any you want.

Setting it up the same way as the Node samples in the Appium samples folder will result in these packages.

8

The capabilities you need to set to run the test cases are the same as the ones used for the inspect session. Platform “Windows” and devicename “windowsPC” with for Store Apps the full app name and for desktop apps the location of the executable.

10

The test case is a simple sequence of actions with a validation.

11

The testcases and environment are ready fir execution. Simply start  the run via the command line. This works for desktop apps and for store apps. Don’t forget to set the Windows 10 environment in Developer mode.

test3

See the GitHub Project 

Add comment


Şarkı Sozleri