Automating the Windows Desktop Calculator’s UI using Winium

Ever since I learned how to use Selenium to automate browsers and web applications a few years back, I’ve wondered from time to time whether I can use the same process or technology to automate Windows desktop applications via its user interface. There’s no particular use case at work considering our apps are all in the web, but I challenged myself to find an answer only for curiosity’s sake. It didn’t turn out to be a thought-provoking experiment but at least it was somehow amusing.

Here’s what I got from the quick study:

Click the image to view the GIF full-size on another browser tab 🙂

And a few notes:

  • We can’t use Selenium to automate Windows desktop applications.
  • A quick search about automating Windows apps tells us that there’s actually a number of tools we can use for such purpose, some paid, others free. Other than Winium, I found out that we can also use Sikuli (or its successor SikuliX), WinTask, autoIT, TestStack.White, Automa, MacroSchedulerCobra, or Pywinauto. There’s probably more tools out there. I just chose to use Winium because writing tests and automating the app with it is similar to how Selenium works, which means very little learning curve for me.
  • Source code for this short experiment can be found here: Win-Calculator. It uses Maven for handling installation of project dependencies while the test code is written in Java. The tests run locally, I’m not sure whether there’s a way to manipulate a Windows app on another machine using Winium. I have not researched that far.
  • Winium will actually take control of the machine’s mouse to move to the element locations set in the tests. This means that interrupting the position of the mouse while the tests are running would likely fail the test. This is annoying, and I’m not sure whether the other Windows app automation tools behave otherwise or the same.

8 thoughts on “Automating the Windows Desktop Calculator’s UI using Winium

    • Hi Sathish,

      At the time, I used Microsoft’s UI Spy tool. I checked again and it seems that UI Spy is now obsolete, and they now recommend using Microsoft Inspect for locating app elements. In any case, whatever tool you use for locating elements, what matters is you get the proper locator and it will work in Winium. 🙂


  1. Hi, i am using winium tool to automate java desktop application. but the problem is some button, tab and layout doesn’t have a name, id and class name then how can i automate these button and tab. kindly help me out.

    • Hi Atul,

      I can think of two things, either:
      1) Ask the programmers of the desktop app you’re automating to add a name, id, or class attribute for the particular element, or
      2) Find another attribute you can use to get the element you want to manipulate.

    • Hi Pratik,

      I tested Winium on a Windows 7 machine so I’m not sure whether it’ll work well on a Windows Server one. You can only try. I’m not sure if it’s also practical to test Windows apps with Winium or to focus on units tests.

  2. Hi! Your example doesn’t work on Win10 where the calc application looks different. Can you please offer support for this also? Thank!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s