Select Page

Category Selected: Desktop App Automation Testing

4 results Found


People also read

API Testing

How to Perform API Test Automation using Rest Assured?

Software Development

Why use React JS for Web Development?

Data Analytics Testing

The Importance of SQL for QA Engineers

Talk to our Experts

Amazing clients who trust us


image
image
image
image
image
image
How to Automate a Desktop Application using C#?

How to Automate a Desktop Application using C#?

Despite the rise of people using mobile applications, desktop applications are still being used on a daily basis by many. Though you can test a desktop application manually, it is still important for a tester to know how to automate desktop applications in Windows. There are a few ways to go about it, and in this blog, we will be focusing on how to automate a desktop application using C#. In order to achieve that, we’ll be sharing the tried and tested frameworks, tools, strategies, and approaches we have been using over the years to deliver exceptional automated desktop application testing services to our clients. We’ve also provided an example to help you understand everything clearly. So let’s get started.

.NET Framework

.NET Framework is a software development platform developed by Microsoft to build and run windows applications. .NET is used to automate applications in different operating systems such as Linux, macOS, and Windows. Whereas, .NET framework was developed specifically for Windows. So it can be used to run applications in windows environments that were created using the .NET framework.

WinAppDriver (Windows Application Driver)

WinAppDriver is also a test automation framework developed by Microsoft. It is an open-source option that feels like a combination of a WebDriver and Appium. We say this as WinAppDriver is a set of libraries that can be integrated into a test runner that supports Appium. For those who don’t know, Web drivers are used for desktop application automation and Appium is used for mobile app automation. Before we proceed to see how to automate a Desktop application using C#, let’s take a look at the prerequisites for WinAppDriver

  • Windows 10 OS
  • Visual Studio 2013+
  • WinAppDriver.exe
  • Turn ON Developer mode on the PC

BDD Approach

We have used the BDD approach in numerous automation testing projects and have always been satisfied with the results. That is why we have decided to focus on it while explaining how to automate a desktop application using C#. BDD is expanded as Behavior Driven Development, it is an Agile software development process that allows the design, creation, and product testing, using the product’s behavior.

But the major advantage is that it makes it very easy for even non-technical users to understand the purpose of every test without having to know technical terms like classes, methods, and variables. All the important aspects will be explained using Gherkin language that is in the Given, When, and Then format.

Since we will be automating Notepad in our example, we’ve created a feature file in the Gherkin language for easier understanding.

@Demo 
Scenario: Notepad Demo
	Given Launch Notepad 
	When Enter Specified Text
	Then Verify the Entered Text

Specflow

Now that we have discussed the approach we’ll be using, let’s focus on the Specflow, the solution that can be used to implement BDD in our framework. We can use the Gherkin language as mentioned above and bind the steps definitions for desktop applications. If you haven’t yet installed Specflow, you can easily do so by using the NuGet manager in any Visual Studio project.

Inspectors

When it comes to web automation, we can find different locators by inspecting the webpage. But that will not be possible when it comes to desktop app automation. That is why knowing how to use a UI Inspector is a crucial part of learning how to automate a desktop application using C#.

Inspectors used for Desktop Applications:

  • FlaUInspect
  • UIspy
  • Inspect
  • VisualUIAVerify

Using either one of these UI inspectors, you’ll be able to see the DOM of the desktop application and get the locators of elements such as ID, Name, ClassName, XPath, and so on.

How to Automate a Desktop Application using C#?

First up, we’ll need to create a new project in Visual Studio using the Console App (.NET Framework)

Create a new project to automate a Dektop application

Install Specflow

We have to then install and set Specflow up by

  • Navigating to Project > Manage NuGet Packages
  • Search for Specflow and click on Specflow to install it
  • We have to then add Specflow.NUnit and Specflow.Tools.MsBuild.Generation from the same NuGet packages

Installing Specflow

Installing WinAppDriver

We need to install WinAppDriver from GitHub to launch and access the desktop application we wish to automate. WinAppDriver will create a bridge for the application and our tests. You’ll have to enable the developer mode in Windows to run WinAppDriver.

To access the WinAppDriver classes and methods, we need to add Appium.Webdriver to our project from NuGet packages

Installing WinAppDriver to automate a desktop Application using C#

The next step would be to Create a Feature file. You can do so by right-clicking on the Feature folder > Add > New item > Search for Feature File for Specflow as shown in the below image.

Creating a feature file in WinAppDriver

Framework Setup

Now that everything is installed and ready, we’ll be seeing how to set up the framework in our How to automate a desktop application using C# blog. You’ll have to,

Create a windowsUtils Class file

Taking screenshots during test execution and generating reports is an integral part of knowing how to automate a desktop application using C#. And you’ll need the windowsUtils class file to achieve that.

public class windowsUtils
    {
        static WindowsDriver<WindowsElement> window;

        static windowsUtils()
        {
            Console.WriteLine("\n ----> Enter into Static block :: WINDOWUtil");

            window = LaunchApp("C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Accessories\\Notepad.lnk");
        }
        public static WindowsDriver<WindowsElement> getWindowInstance()
        {
            Console.WriteLine("---> Enter into Get Windows Method...");
            return window;
        }
        public static WindowsDriver<WindowsElement> LaunchApp(String _ApplicationLocation)
        {
            Console.WriteLine("\n Window Util :: Launch App Method....");
            try
            {

                AppiumOptions options = new AppiumOptions();
                options.AddAdditionalCapability("app", _ApplicationLocation);
                options.AddAdditionalCapability("deviceName", "WindowsPc");
                window = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723/"), options);

            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception for Launch App : " + ex.Message);
            }

            return window;
        }
Create a class file for the Base window

We’ll next have to use WinAppDriver to perform Desktop App Automation testing. So we have mentioned the code you’ll need to use to create the class file for the Base window.

 public class baseWindow
    {
        public WindowsDriver<WindowsElement> window;
        public baseWindow(WindowsDriver<WindowsElement> window)
        {
            Console.WriteLine("---> Base Window... Constructor..");
            this.window = window;
        }
        public WindowsDriver<WindowsElement> getWindowInstance(String _ApplicationLocation)
        {
           
            try
            {
                AppiumOptions options = new AppiumOptions();
                options.AddAdditionalCapability("app", "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Accessories\\Notepad.lnk");
                options.AddAdditionalCapability("deviceName", "WindowsPc");
                window = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723/"), options);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception for getWindowInstance : " + ex.Message);
            }

            return window;
        }
Create a class file for the Methods

We then create a class for the methods to perform the required action in the desktop application. In our case, we have chosen Notepad. And we will be entering the word “Codoid Innovations” and validating if the specified text has been displayed.

public class Notepad : baseWindow
    {
        static WindowsDriver<WindowsElement> _window;
        public Notepad(WindowsDriver<WindowsElement> window) : base(window)
        {
            _window = this.window; 
        }
        public By Text => By.Name("Text Editor");
        public By Verifyinput => By.Name("Text Editor");
        public void Maximize()
        {
          window.Manage().Window.Maximize();
        }
        public void enterText()
        {
            window.FindElement(Text).SendKeys("Codoid Innovations");
        }
        public bool VerifytheText()
        {
            bool result = window.FindElement(Verifyinput).Displayed;
            return result;
        }
}
Run the Test

Finally, we can run the test by opening the command prompt from the file location and using the following command

“nunit3-console.exe filename –where “cat==tagname from the feature file””

C: \Demo\DemoAutomation\DemoAutomation\bin\Debug>nunit3-console.exe DemoAutomation.dll --where "cat==Demo"

Conclusion

We hope you now have a clear picture of how to automate a desktop application using C# after reading our blog. As a pioneer automation testing company, we have even developed our very own desktop app automation tool called Gyra. If you are unfamiliar with C#, give Gyra a try as it is a free tool that works with Java. We will be publishing more informative content on our website, and we recommend you subscribe to our newsletter to not miss out on any of those content.

Desktop App Automation Testing using Python

Desktop App Automation Testing using Python

In this blog article, you will learn Desktop app automation testing using Python. Automating a desktop app is not an easy task using open-source tools. In the past, we wrote many blog articles on how to automate desktop applications test cases using White Framework.

However, today we would like to show you how to automate a desktop app using Python.

Required Packages

To automate desktop app, we need the following packages (pyWin32, comtypes, & six). Use the below Pip command to install all the three packages.

pip install pywinauto  

Launching An Application

from pywinauto.application import Application
app = Application().start("notepad.exe")
  

Inspecting Elements

You can use anyone of the below listed inspecting tools to write locators.

  • AccEvent.exe
  • AccExplorer32.exe
  • Inspect.exe
  • SPYXX.EXE
  • swapy-ob-0.4.3.exe
  • UISpy.exe
  • ViewWizard.exe
  • WSEdit.EXE

Locating windows by title

app.window(title="Untitled - Notepad").menu_select("Help->About Notepad")
  

Locating with regular expression

app.window(title_re='.* - Notepad$')
  

Finding a window with multiple properties

window = findwindow(title = "Untitled - Notepad", class = "Notepad")

Print Identifiers

Use the below command to print all the identifiers on a window.

app.window(title="Untitled - Notepad").print_control_identifiers()  

Other Actions

app.UntitledNotepad.menu_select("File->SaveAs")
app.SaveAs.ComboBox5.select("UTF-8")
app.SaveAs.edit1.set_text("Example-utf8.txt")
app.SaveAs.Save.click()
  

We explored this library with excitement. Desktop app automation testing using Python library is more user-friendly and the execution is also much faster than other implementations.

How to automate desktop application test cases

How to automate desktop application test cases

Automating desktop app test cases using open source tools is an herculean task. It requires complete understanding of your application’s technology and in-depth knowledge of how your OS interacts with desktop applications. For example: If you are automating a Windows desktop application, you should be aware of how Windows Event-driven programming interacts with your application. In this blog article, we will see most of the technical information based on Windows application.

Technologies for windows desktop app development

Knowing the technologies for Windows desktop app development is a key information to decide a right automation tool. If you take any Windows based desktop application, it must have been developed using the following package/framework Windows API, MFC (Microsoft Foundation Classes), and .NET. When you choose a test automation tool, just check whether these technologies are supported.

How to automate desktop application test cases

How Windows Works

Consider your software under test is developed using Windows API. Each application window is assigned with Window Handle (hwnd). Once the user depresses the left mouse button on the application window, then Windows OS will construct a message and send it to the designated window using hwnd.

Automating Windows Desktop Application

From our experience, we recommend the following libraries (White Framework, FlaUI, .NET UI Automation, and Win32 Library for .net) to automate desktop applications. Choosing a tool is a cakewalk. However, selecting an unique identifier to locate a Windows object is tricky. Automating Desktop application test cases using coordinates is not a good idea. You always need to write robust locators to achieve consistency in automated script execution. Use Object Spy, understand the underlying technology, and perform trail & error method to construct valid object locators.

Automating Windows Desktop Application

In Conclusion:

Don’t automate Desktop Application Test suite without doing a POC. Make sure you engage a test automation architect who has vast experience in automating Desktop, Web, and Mobile applications.

All about Desktop Application Testing

All about Desktop Application Testing

Desktop applications require a human to run them and work separately as full-function programs and independently of all other applications. Adequate and proper hardware and a set of functions are required for accurate desktop application testing. This testing is complex and intricate since most are developed for a particular environment, and hence interaction with other factors is nil. In addition, a number of computer systems with varying configurations are required for this type of testing, but the tester has the ability to completely control the application under test.

Understanding Desktop Applications

Specific environments act as the model or starting point of a test plan. It is possible to test an application under classifications such as load, functionality, GUI, and more, and since desktop applications are normally in use by a single user at a given point, it must be installed as an exe file.

There is of course a significant rise in mobile and handheld device technology, but desktops are still used, and hence businesses must ensure that the applications for such systems are ready to function when installed. It is necessary that desktop applications are not ignored and made part of QA programs and any top quality QA Outsourcing company will understand the importance of such applications and will ensure that your business has the best.

Just as with any applications and systems, desktop applications need deft management since if poorly running and defective, they can negatively impact business, increase costs, and lead to a severe dent in the reputation of a company.

Running desktop applications is about testing applications on personal computers, desktop computers, and other such devices, and testing is run to check functionality, security, usability, stability, and more. If companies have the resources both money and human, to invest in this type of testing it would make sense to have an in-house team. However, since such testing has stringent deadlines and requires a high level of quality control, most businesses may find themselves incompetent to deal with it. It would make more business sense to outsource this function to a top quality QA testing company, capable of delivering more for every resource invested. Such a company would not only help to bring down costs and overheads of managing such tests, but would also ensure that the software remains efficient and speedy across all the stages.

Common Errors in Desktop Applications

The kind of errors in desktop application is different to other applications, which is why they require professionals to manage them.

  • 1. Inaccurate and unauthorized features auto installed by the application, without input from the user
  • 2. Wrong shortcut icon
  • 3. Issues related to dependence on platform
  • 4. Background running of a process even post uninstallation of application
  • 5. Incorrect warning / error messages
  • 6. Unauthorized access to users to even restricted applications

A Checklist for Desktop Application Testing is Necessary

Anyone excelling in the realm of testing would know that a checklist is quintessential when writing test cases, and in the case of desktop applications too such a checklist would help to create a high number of test cases. The testing checklist should include the following tests:

  • 1. Testing GUI or Graphical User Interface
  • 2. Functional Testing
  • 3. Performance testing under normal and load conditions
  • 4. Compatibility Testing

There are several tools that are part of industry practice to assist with desktop application testing. A highly seasoned software testing company would have the latest tools, technology, and methodologies for this purpose. The tools include a variety of regression testing and stress testing tools. Such a company would also understand that since there are some key differences between web applications and desktop applications, their handling and testing would also be different and must be managed as so.

In Conclusion:

The ownership, responsibility and accountability of a desktop application tester are very different to that of a web or client server applications tester. Understanding these differences proves critical to ensure that product quality is of the highest order and a highly expert team of desktop application testers would always remain on point. Connect with us to access the best in class team of experts.