In this blog post we will explore how to use Appium, the Microsoft recommended open source test automation framework, with Telerik UI for WinForms.
You are probably aware that the Coded UI Test for automated UI-driven functional tests has been deprecated—in the release notes for Visual Studio 2019, Microsoft confirmed that Visual Studio 2019 will be the final version with Coded UI test features.
Currently, Microsoft recommends using Appium with WinAppDriver as a UI test tool for desktop and UWP applications. WinAppDriver is a service that supports Selenium-like UI Test Automation on Windows Applications.
By now, you are probably wondering whether it's possible to automate Telerik UI for WinForms controls with Appium? Well, it's your lucky day—in the following paragraphs we will walk you through the process of using Appium for Telerik UI for WinForms controls.
None mandatory but may come in use depending on your test scenarios and architecture:
Here are the steps to write a WinAppDriver test:
Rename the auto generated “UnitTest1” class to “RadControlsScenarios” which should inherit “TestSession.” Here is the place to mention that our sample test application consists of RadGridView, RadButton and RadDropDownButton controls.
Next, we should create “ClassInitialize” and “ClassCleanup” methods.
There are two general ways to write tests: Using WinAppDriver UI Recorder tool to record tests at runtime and writing tests from scratch using inspect.exe tool for locating elements in your application.
Launch the WinAppDriver UI Recorder and click “Record.” Hover over the “radButton1” and wait until it starts flashing blue. The Recorder’s status bar will change its text from “Active” to “XPath Ready.” Once you have recorded a sequence of steps you wish to reproduce, click “Pause” within the recorder. You can open the actions selector to make certain that all UI actions have been recorded.
All you need to do now is to click the “Generate and copy C# code to Clipboard” button to copy the code for all recorded actions. Paste this code into the TestMethod.
Now lets write two more tests from scratch. The first scenario is deleting a row from radGridView Context Menu and verifying the radGridView rows count.
Let’s continue with a scenario where we click a radDropDownButton, followed by radMenuItem in order to change the ApplicationThemeName.
Create a public static class WindowsElementExtensions.cs and define the FindElementByAbsoluteXPath method. You will need that if you use the UI Recorder tool for your tests.
Additionally, here you can write helper methods such as DoubleClick, RightClick or Click with a X and Y offset in order to test different scenarios.
Right-click the Unit Test project in Visual Studio and click “Run Tests”. The test will launch your application, repeat all recorded steps, and close the application afterwards. All test activity is logged in the WinAppDriver console.
I hope this walk-through was beneficial for you—if you are using Telerik UI for WinForms and have any questions regarding test automation with Appium, don't hesitate to contact us! Our team would be delighted to help.
Dimitar Ivanov is a quality assurance engineer in Telerik UI for WinForm team. He joined the company at the beginning of 2018. Apart from his job, Dimitar likes playing video games or board games with his friends but most of all - drinking ice cold beer.
Subscribe to be the first to get our expert-written articles and tutorials for developers!