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.

If You Want To Learn How To Write Selenium Webdriver Automated Checks

.. here’s a list of online courses I took last year in order to learn how to use Selenium Webdriver (an open source tool that automates browsers):

It’s not a comprehensive list but they are enough to get you started. The first two in the list are free courses, the last two are paid (I always wait for a $10 sale before purchasing the more expensive courses since uDemy does that a lot anyway), all of them will of course require you to have a uDemy account to access them. I learned a bunch from these tutorials, even though it can sometimes be difficult to listen to Indian instructors, even though they won’t have all the answers that you need. A lot of the more important lessons in implementing successful automated test suites will come from the experience of using the tool, from debugging test code, from looking for answers on the main Selenium documentation or StackOverflow, and from following blogs of software testers who have used Selenium far longer than we have. But do check them out, especially the free ones, if you are into web testing and you are curious about how Webdriver works. 🙂