Automating the Windows 7 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.

12 thoughts on “Automating the Windows 7 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. 🙂

      Jason

      Reply
      • Hi Jason, are you absolutely sure about this, I’m asking because, last time I used Inspect, my Antivirus marked it as a trojan, plus it also caused to create new svchost.exe, etc. files that slowed down my PC majorly.

        I’ve been using UI Spy since, It works fine though not at all times

  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.
    thanks

    Reply
    • 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.

      Reply
    • 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.

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

    Reply
  3. I am using winium to automate desktop application. but when i am locating element, some of the element is locating fast and some of them is locating very slow while executing the code. Why?

    Reply
  4. Pingback: Automating the Windows 10 Desktop Calculator using PyAutoGui | One Software Tester

Leave a reply to OanaT Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.